#include using namespace std; bool is_SPRP(uint64_t n, uint64_t a) { uint64_t s = __builtin_ctzll(n - 1), d = (n - 1) >> s, cur = 1; for (uint64_t pw = d; pw; pw >>= 1) { if (pw & 1) cur = ((__uint128_t)cur * a) % n; a = ((__uint128_t)a * a) % n; } if (cur == 1) return true; for (; s--; cur = ((__uint128_t)cur * cur) % n) if (cur == n - 1) return true; return false; } bool is_prime(uint64_t x) { if (x <= 1) return false; vector bases{2, 325, 9375, 28178, 450775, 9780504, 1795265022}; if (x < 1ull << 32) bases = {2, 7, 61}; for (const uint64_t base : bases) if (x != base && !is_SPRP(x, base)) return false; return true; } int main() { int q; cin >> q; while (q--) { long long n; cin >> n; cout << n << " " << is_prime(n) << endl; } }