#include using namespace std; using Int8 = int8_t; using Int16 = int16_t; using Int32 = int32_t; using Int64 = int64_t; using Int128 = __int128_t; using Word8 = uint8_t; using Word16 = uint16_t; using Word32 = uint32_t; using Word64 = uint64_t; using Word128 = __uint128_t; using Int = int_fast64_t; using Word = uint_fast64_t; using F32 = float; using F64 = double; using F80 = long double; using VS = vector; using VVS = vector>; using VB = vector; using VVB = vector>; using VI = vector; using VW = vector; using VVI = vector>; using VVW = vector>; using PII = pair; using PWW = pair; using VPII = vector>; using VPWW = vector>; #define LOOP(n) for(Int _ipiewnsjiw=0; _ipiewnsjiw<(n); _ipiewnsjiw++) #define REP(i,n) for(Int i=0, i##_len=(n); i= (Int)M); } Word power(Word b, Word e, Word mod) { Word ans = 1; for (; e; b = mult(b, b, mod), e /= 2) if (e & 1) ans = mult(ans, b, mod); return ans; } int miller_rabin(Word n) { if (n < 2 || n % 6 % 4 != 1) return (n | 1) == 3; Word A[] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}, s = __builtin_ctzll(n-1), d = n >> s; for (Word a : A) { Word p = power(a % n, d, n), i = s; while (p != 1 && p != n - 1 && a % n && i--) p = mult(p, p, n); if (p != n-1 && i != s) return 0; } return 1; } int main() { int Q; cin >> Q; while (Q--) { Word x; cin >> x; cout << x << ' ' << miller_rabin(x) << '\n'; } return 0; }