#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< class T> T pow_ (T x, T n, T M){ T u = 1; if(n > 0){ u = pow_(x, n/2, M); if (n % 2 == 0) u = (u*u) % M; else u = (((u * u)% M) * x) % M; } return u; }; bool suspect(__uint128_t a, __uint128_t s, __uint128_t d, __uint128_t n){ __uint128_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 = x * x % n; } return false; } template bool miller_rabin(T m){ __uint128_t n = m; if (n <= 1 || (n > 2 && n % 2 == 0)) return false; __uint128_t d = n - 1, s = 0; while (!(d&1)) {++s; d >>= 1;} static const __uint128_t v[] = {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; }