#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)md); } Int power(Int a, Int b, Int md) { a %= md; Int ans = 1; while (b > 0) { if (b & 1) ans = mult(ans, a, md); a = mult(a, a, md); b >>= 1; } return ans; } int miller_rabin(Int n) { if (n < 2 || n % 6 % 4 != 1) return (n | 1) == 3; Int s = __builtin_ctzll(n - 1); Int d = n >> s; Int A[7] = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; for (Int a : A) { Int 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--) { Word64 x; cin >> x; cout << x << ' ' << miller_rabin(x) << '\n'; } return 0; }