#include "bits/stdc++.h" using namespace std; #ifdef _DEBUG #include "dump.hpp" #else #define dump(...) #endif //#define int long long #define rep(i,a,b) for(int i=(a);i<(b);i++) #define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--) #define all(c) begin(c),end(c) const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f; const int MOD = 1'000'000'007; template bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; } template bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; } // 累乗 // O(log e) // mod^2 が T の最大値より大きければオーバーフローするので掛け算に modmul を使う template T modpow(T a, T e, T mod) { T res = 1; while (e > 0) { if (e & 1)res = res * a % mod; // modmul(res, a, mod); a = a * a % mod; // modmul(a, a, mod); e >>= 1; } return res; } // 素数判定(Miller-Rabin primality test) // 2^24程度から // millerRabinPrimalityTest(n, 5) template bool millerRabinPrimalityTest(T x, int iteration) { if (x < 2)return false; if (x != 2 && x % 2 == 0)return false; T s = x - 1; while (s % 2 == 0)s /= 2; for (int i = 0; i < iteration; i++) { T a = rand() % (x - 1) + 1, tmp = s; T mod = modpow(a, tmp, x); while (tmp != x - 1 && mod != 1 && mod != x - 1) { mod = mod * mod % x; tmp *= 2; } if (mod != x - 1 && tmp % 2 == 0)return false; } return true; } using u128 = __uint128_t; signed main() { cin.tie(0); ios::sync_with_stdio(false); int n; cin >> n; rep(_, 0, n) { long long x; cin >> x; cout << x << " " << millerRabinPrimalityTest(u128(x), 10) << endl; } return 0; }