ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules

1204. Idempotents

Time limit: 1.0 second
Memory limit: 64 MB
The number x is called an idempotent modulo n if
x*x = x (mod n)
Write the program to find all idempotents modulo n, where n is a product of two distinct primes p and q.

Input

First line contains the number k of test cases to consider (1 ≤ k ≤ 1000). Each of the following k lines contains one number n < 109.

Output

Write on the i-th line all idempotents of i-th test case in increasing order. Only nonnegative solutions bounded by n should be printed.

Sample

inputoutput
3
6
15
910186311
0 1 3 4
0 1 6 10
0 1 303395437 606790875
Problem Author: Pavel Atnashev
Problem Source: USU Internal Contest, March 2002