#include using namespace std; using ll = long long; #ifdef tabr #include "library/debug.cpp" #else #define debug(...) #endif bool is_prime(unsigned long long n) { if (n < 2) { return false; } vector bases = {2, 325, 9375, 28178, 450775, 9780504, 1795265022}; unsigned long long s = __builtin_ctzll(n - 1), d = n >> s; for (auto a : bases) { unsigned long long p = 1, i = s, j = d, k = a; while (j > 0) { if (j & 1) { p = (__int128)p * k % n; } k = (__uint128_t)k * k % n; j >>= 1; } while (p != 1 && p != n - 1 && a % n && i--) { p = (__uint128_t)p * p % n; } if (p != n - 1 && i != s) { return false; } } return true; } int main() { ios::sync_with_stdio(false); cin.tie(0); int n; cin >> n; for (int i = 0; i < n; i++) { ll x; cin >> x; cout << x << " "; int j = 0; if (is_prime(x)) { j = 1; } cout << j << '\n'; } return 0; }