#include using namespace std; using value_type = __uint128_t; class XorShift { private: uint32_t x = 123456789; uint32_t y = 362436069; uint32_t z = 521288629; uint32_t w; public: XorShift(uint32_t seed = 0) : w(seed ? seed : 88675123) {this->random_loop();} void random_loop() { int loop_num = this->next_int() % 50; while (loop_num--) this->next_int(); } uint32_t next_int(bool heavy_ok = false) { if (heavy_ok) this->random_loop(); uint32_t t = this->x ^ (this->x << 11); this->x = this->y; this->y = this->z; this->z = this->w; return this->w = (this->w ^ (this->w >> 19)) ^ (t ^ (t >> 8)); } uint64_t next_long(bool heavy_ok = false) { return ((((uint64_t)this->next_int(heavy_ok)) << 32) | this->next_int(heavy_ok)); } uint32_t operator()(bool heavy_ok = false) { return this->next_int(heavy_ok); } }; 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; } } XorShift rnd; //random_device rnd; bool miller_labin(value_type n, int loopNum = 100) { 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; }