#include using namespace std; // N <= 1e9 -> long long // N > 1e9 -> int128 template int MillerRabin(const T N, int challenge = 10) { if (N <= 1) return 0; if (N == 2) return 1; T M = N - 1,cnt = 0; for (; M % 2 == 0; M /= 2,cnt++); mt19937 mt(time(NULL)); for (int i = 0; i < 10; ++i) { T a = uniform_int_distribution(2, N - 1)(mt), r = 1; for (T K = M; K > 0; K >>= 1, (a *= a) %= N) if (K & 1) (r *= a) %= N; if (r == 1) continue; for (int j = 1; j < cnt && r != N - 1; j++) (r *= r) %= N; if (r != N - 1) return 0; } return 1; } int main() { long long N; cin >> N; vector A(N); for(int i = 0; i < N; ++i) cin >> A[i]; for(int i = 0; i < N; ++i) { cout << A[i] << " " << MillerRabin<__int128_t>(A[i]) << endl; } return 0; }