// #include "../../merge_src_docs/template/24_template.hpp" #include using namespace std; using ll = long long; #define rep(i, n) for(ll i = 0; i < n; i++) #define rep2(i, l, r) for(ll i = l; i < r; i++) using vi = vector; using vvi = vector; using vll = vector; #define all(A) A.begin(), A.end() #define elif else if using pii = pair; bool chmin(auto &a, auto b) { return a > b ? a = b, 1 : 0; } bool chmax(auto &a, auto b) { return a < b ? a = b, 1 : 0; } struct IOSetup { IOSetup() { cin.tie(0); ios::sync_with_stdio(0); } } iosetup; template void print(vector a) { for(auto x : a) cout << x << ' '; cout << endl; } void print(auto x) { cout << x << endl; } template void print(Head &&head, Tail &&...tail) { cout << head << ' '; print(forward(tail)...); } // #include "../../merge_src_docs/math/fast_prime.hpp" using i128 = __int128_t; template T pow_mod(T x, U n, T m) { T r = 1 % m; x %= m; while(n) { if(n & 1) r = (r * x) % m; x = (x * x) % m; n >>= 1; } return r; } bool is_prime(ll n) { if(n <= 1) return false; if(n == 2) return true; if(n % 2 == 0) return false; ll d = n - 1; while(d % 2 == 0) d /= 2; vll a_list = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}; // vll a_list; // if (n < (1 << 30)) { // a_list = {2, 7, 61}; // } else { // a_list = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; // } for(auto a : a_list) { if(n <= a) break; ll t = d; ll y = pow_mod(a, t, n); while(t != n - 1 && y != 1 && y != n - 1) { y = i128(y) * y % n; t <<= 1; } if(y != n - 1 && t % 2 == 0) return false; } return true; } mt19937_64 rng(2024); // [0, 2^64) ll randint(ll l, ll r) { return l + rng() % (r - l + 1); } ll pollard(ll n) { ll R; auto f = [&](ll x) { return (i128(x) * x + R) % n; }; if(is_prime(n)) return n; if(n % 2 == 0) return 2; ll st = 0; while(true) { R = randint(1, n); st++; ll x = st, y = f(x); while(true) { ll p = gcd((y - x + n), n); if(p == 0 || p == n) break; if(p != 1) return p; x = f(x); y = f(f(y)); } } } // n の素因数分解をする.順番はランダム. vll factor(ll n) { if(n == 1) return {}; ll x = pollard(n); if(x == n) return {n}; vll l = factor(x); for(auto p : factor(n / x)) l.push_back(p); return l; } // https://yukicoder.me/problems/1967 void solve1() { ll T; cin >> T; while(T--) { ll N; cin >> N; cout << N << ' ' << is_prime(N) << '\n'; } return; } void solve2() { return; } int main() { solve1(); return 0; }