Junk or Joy

아직 제출이 없습니다시간 제한2초메모리 제한512 MB

문제

You are given a positive integer kk. Find the number of tuples of positive integers (n,p,m)(n, p, m) such that n2kpm=1n^2 - k \cdot p^m = 1 and pp is a prime number, or report that an infinite number of such tuples exists.

입력

Each test contains multiple test cases. The first line contains the number of test cases tt (1t1001 \le t \le 100). Description of the test cases follows.

The only line of each test case contains a single integer kk (1k1091 \le k \le 10^9).

출력

For each test case, print the number of positive integer tuples (n,p,m)(n, p, m) such that n2kpm=1n^2 - k \cdot p^m = 1 and pp is a prime, or 1-1 if there's an infinite number of them.

힌트

In the first example test case, for k=5k = 5, the only possible tuples are (4,3,1)(4, 3, 1), (6,7,1)(6, 7, 1), and (9,2,4)(9, 2, 4).

In the second example test case, for k=22k = 22, no possible tuples exist.