Simon Haples is a somewhat peculiar person. Not quite hip, not quite square, he is more of a triangular nature: ever since childhood, he has had an almost unhealthy obsession with triangles. Because of his discrete nature, Simon’s fa- vorite kind of triangles are the Pythagorean ones, in which the side lengths are three positive integers a, b, and c such that a ≤ b and a2 + b2 = c2. Recently, Simon has discovered the fantastic world of counting modulo some integer n. As you may imagine, he quickly realizes that there are multitudes of Pythagorean triples to which he has previously been oblivious! Simon therefore sets out to find all Pythagorean triples modulo n, i.e., all triples of integers a, b and c between 1 and n − 1 suchthata≤banda2+b2 ≡c2 (modn). As Simon’s best friend, you realize that there is not much hope in deterring Simon from his crazy plans, so you decide to help him by computing how many such triples there are, so that Simon will know when his work is done. Input The input file contains several test cases, each of them as described below. The input consists of a single integer n, satisfying 2 ≤ n ≤ 500 000. Output For each test case, write to the output, on a line by itself, the number of Pythagorean triples modulo n. Sample Input 7 15 Sample Output 18 64