#include #include #include #include typedef uint32_t u32; typedef uint64_t u64; u64 mul (u64 a, u64 b, u64 mod) { u64 ans = 0; while (b > 0) { if (b & 1) { ans += a; if (ans >= mod) ans -= mod; } a += a; if (a >= mod) a -= mod; b >>= 1; } return ans; } u64 mod_pow (u64 a, u64 n, u64 mod) { u64 t = 1; while (n > 0) { if (n & 1) t = mul (t, a, mod); a = mul (a, a, mod); n >>= 1; } return t; } u64 xor_shift (void) { static u64 x = (u64)88172645463325252; x ^= x << 7; return x ^= x >> 9; } u32 is_prime_miller (const u64 p, u32 iter) { if (p <= 1) return 0; if (p <= 3) return 1; if (p % 2 == 0) return 0; u64 d = p - 1; u32 s = 0; while (d % 2 == 0) { d /= 2; s++; } while (iter--) { u64 a = xor_shift() % (p - 1) + 1; a = mod_pow (a, d, p); if (a == 1) continue; u32 i = 0; for (; i < s && a != p - 1; ++i, a = mul (a, a, p)); if (i >= s) return 0; } return 1; } void run (void) { u32 n; scanf ("%" SCNu32, &n); while (n--) { u64 x; scanf ("%" SCNu64, &x); printf ("%" PRIu64 " %" PRIu32 "\n", x, is_prime_miller (x, 15)); } } int main (void) { run(); return 0; }