#include using namespace std; using value_type = unsigned long long; value_type pow_mod(value_type a, value_type p, value_type mod) { if (p == 0) { return 1; } else if (p & 1) { return a * pow_mod(a, p - 1, mod) % mod; } else { const value_type t = pow_mod(a, p >> 1, mod); return t * t % mod; } } bool miller_labin(value_type n, int loopNum = 1000) { static random_device rnd; if (n == 2) { return true; } if (n < 2 || (!(n & 1))) { return false; } value_type d = n - 1; while (!(d & 1)) { d >>= 1; } while (loopNum--) { value_type a = (((((value_type) rnd()) << 32) | (value_type) rnd()) % (n - 2)) + 1; value_type t = d; value_type y = pow_mod(a, t, n); while (t != n - 1 && y != 1 && y != n - 1) { y = (y * y) % n; t <<= 1; } if (y != n - 1 && (!(t & 1))) { return false; } } return true; } int main() { int n; scanf("%d", &n); while (n--) { long long x; scanf("%lld", &x); printf("%lld %d\n", x, (int) miller_labin(x)); } return 0; }