#include using namespace std; class Random { using T = uint64_t; mt19937_64 mt; random_device rd; public: Random() { seed(); } void seed() { mt.seed(rd()); } void seed(T s) { mt.seed(s); } T operator()() { return mt(); } T operator()(T r) { // [0, r) uniform_int_distribution u(0, 0 < r ? r - 1 : 0); return u(mt); } T operator()(T l, T r) { // [l, r) uniform_int_distribution u(l, max(l, r) - 1); return u(mt); } T dice() { return operator()(1, 7); } bool rand_bool() { return operator()(2); } bool rand_bool(double p) { bernoulli_distribution u(p); return u(mt); } template void shuffle(T& v) { std::shuffle(v.begin(), v.end(), mt); } } rnd; __uint128_t Powmod(__uint128_t a, __int128_t n, __int128_t m) { __uint128_t res = 1; while (n > 0) { if (n & 1) res = res * a % m, n--; else a = a * a % m, n >>= 1; } return res; } bool MillerRabin(const uint64_t n) { if (n == 2) { return true; } else if (n <= 1 || !(n & 1)) { return false; } uint64_t d = n - 1; while (!(d & 1)) { d >>= 1; } for (int _ = 20; _--;) { auto a = rnd(1, n); __int128_t t = d, y = Powmod(a, t, n); while (t != n - 1 && y != 1 && y != n - 1) { y = y * y % n; t <<= 1; } if (y != n - 1 && !(t & 1)) { return false; } } return true; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int32_t n; cin >> n; while (n--) { uint64_t x; cin >> x; cout << x << ' ' << MillerRabin(x) << '\n'; } }