#include #define rep(i, n) for (int i = 0; i < (int)(n); i++) #define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--) #define all(x) (x).begin(), (x).end() #define sz(x) int(x.size()) using namespace std; using ll = long long; const int INF = 1e9; const ll LINF = 1e18; template bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; } template bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; } template vector make_vec(size_t a) { return vector(a); } template auto make_vec(size_t a, Ts... ts) { return vector(ts...))>(a, make_vec(ts...)); } template istream& operator>>(istream& is, vector& v) { for (int i = 0; i < int(v.size()); i++) { is >> v[i]; } return is; } template ostream& operator<<(ostream& os, const vector& v) { for (int i = 0; i < int(v.size()); i++) { os << v[i]; if (i < int(v.size()) - 1) os << ' '; } return os; } namespace factorize { namespace internal { constexpr long long safe_mod(long long x, long long m) { x %= m; if (x < 0) x += m; return x; } constexpr long long pow_mod_constexpr(long long x, long long n, long long m) { if (m == 1) return 0; unsigned long long _m = (unsigned long long)(m); __uint128_t r = 1; __uint128_t y = safe_mod(x, m); while (n) { if (n & 1) r = (r * y) % _m; y = (y * y) % _m; n >>= 1; } return (long long)(r); } constexpr bool is_prime_constexpr(long long n) { if (n <= 1) return false; if (n == 2) return true; if (n == 325 || n == 9375 || n == 28178 || n == 450775 || n == 9780504 || n == 1795265022) return false; if (n % 2 == 0) return false; long long d = n - 1; while (d % 2 == 0) d /= 2; for (long long a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) { if (n <= a) break; long long t = d; long long y = pow_mod_constexpr(a, t, n); while (t != n - 1 && y != 1 && y != n - 1) { y = (__int128_t(y)) * (__int128_t(y)) % n; t <<= 1; } if (y != n - 1 && t % 2 == 0) { return false; } } return true; } } // namespace internal } // namespace factorize using namespace factorize; int main() { int n; cin >> n; rep(_, n) { ll x; cin >> x; cout << x << ' ' << internal::is_prime_constexpr(x) << '\n'; } }