{"raw_statement":[{"iden":"problem statement","content":"You are given $N$ integers $A_1,\\ldots,A_N$ and a prime number $P$. Find the number of pairs of integers $(i,j)$ that satisfy both of the following conditions:\n\n*   $1 \\leq i,j \\leq N$;\n*   There is a positive integer $k$ such that $A_i^k \\equiv A_j \\mod P$."},{"iden":"constraints","content":"*   $2 \\leq N \\leq 2 \\times 10^5$\n*   $1 \\leq A_i < P$\n*   $2 \\leq P \\leq 10^{13}$\n*   $P$ is prime.\n*   All input values are integers."},{"iden":"input","content":"The input is given from Standard Input in the following format:\n\n$N$ $P$\n$A_1$ $\\ldots$ $A_N$"},{"iden":"sample input 1","content":"3 13\n2 3 5"},{"iden":"sample output 1","content":"5\n\nFive pairs satisfy the conditions: $(1,1),(1,2),(1,3),(2,2),(3,3)$.\nFor example, for the pair $(1,3)$, if we take $k=9$, then $A_1^9 = 512 \\equiv 5 = A_3 \\mod 13$."},{"iden":"sample input 2","content":"5 2\n1 1 1 1 1"},{"iden":"sample output 2","content":"25"},{"iden":"sample input 3","content":"10 9999999999971\n141592653589 793238462643 383279502884 197169399375 105820974944 592307816406 286208998628 34825342117 67982148086 513282306647"},{"iden":"sample output 3","content":"63"}],"translated_statement":null,"sample_group":[],"show_order":["default"],"formal_statement":null,"simple_statement":null,"has_page_source":true}