#include using namespace std; long long pow_mod(long long x, long long n, long long m) { assert(0 <= n && 1 <= m); if (m == 1) return 0; __int128 r = 1, y = (x % m + m) % m; while (n > 0) { if (n & 1) r = r * y % m; y = y * y % m; n >>= 1; } return r; } bool is_prime(long long n) { if (n <= 1) return false; constexpr long long bases[12] = {2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37}; for (long long a : bases) if (n == a) return true; if (n % 2 == 0) return false; long long d = n - 1; int t = __builtin_ctzll(d); d >>= __builtin_ctzll(d); for (long long a : bases) { if (a >= n) break; int i = t; __int128 y = pow_mod(a, d, n); while (i-- && y != 1 && y != n - 1) y = y * y % n; if (y != n - 1 && i != t) return false; } return true; } int main() { int n; cin >> n; while (n--) { long long x; cin >> x; cout << x << ' ' << is_prime(x) << '\n'; } }