#include using namespace std; __int128_t Powmod(__int128_t a, __int128_t n, __int128_t m) { __int128_t r = 1; while (n > 0) { if (n & 1) r = r * a % m, n--; else a = a * a % m, n /= 2; } return r; } bool MillerRabin(const __int128_t n) { assert(n > 0); if (n == 2) { return true; } else if (n == 1 || n % 2 == 0) { return false; } __int128_t d = n - 1; while (d % 2 == 0) { d /= 2; } for (__int128_t a : {2, 325, 9375, 28178, 450775, 9780504, 1795265022}) { __int128_t t = d, y = Powmod(a, t, n); while (t != n - 1 && y != 1 && y != n - 1) { y = (y * y) % n; t /= 1; } if (y != n - 1 && t % 2 == 0) { return false; } } return true; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int n; cin >> n; while (n--) { long long x; cin >> x; cout << x << ' ' << MillerRabin(x) << '\n'; } }