#include #include #include #include #include #include #include static const int MOD = 1000000007; using ll = long long; using u32 = unsigned; using namespace std; template constexpr T INF = ::numeric_limits::max() / 2; template T mul_ (T x, T y, T M){ T res = 0; for (;y;y/=2) { if (y & 1) res = (res + x) % M; x = (x + x) % M; } return res; } template T pow_ (T x, T n, T M){ if (n == 0) return 1; T res = pow_(x, n/2, M); return mul_(mul_(res, res, M),(n & 1 ? x : 1), M); }; bool suspect(uint64_t a, uint64_t s, uint64_t d, uint64_t n){ uint64_t x = pow_(a, d, n); if (x == 1) return true; for (int r = 0; r < s; ++r) { if(x == n-1) return true; x = mul_(x, x, n); } return false; } template bool miller_rabin(T m){ uint64_t n = m; if (n <= 1 || (n > 2 && n % 2 == 0)) return false; uint64_t d = n - 1, s = 0; while (!(d&1)) {++s; d >>= 1;} const uint64_t v[7] {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; for (auto &&p : v) { if(p >= n) break; if(!suspect(p, s, d, n)) return false; } return true; } int main() { ll n; cin >> n; for (int i = 0; i < n; ++i) { ll k; cin >> k; cout << k << " " << miller_rabin(k) << "\n"; } return 0; }