#include using namespace std; #define rep(i, N) for(int i=0;i<(N);i++) #define all(x) (x).begin(),(x).end() #define popcount(x) __builtin_popcount(x) using ll = long long; //using i128=__int128_t; using ld = long double; using graph = vector>; using P = pair; const int inf = 1e9; const ll infl = 1e18; const ld eps = 1e-6; const long double pi = acos(-1); const ll MOD = 1e9 + 7; const ll MOD2 = 998244353; const int dx[4] = { 1,0,-1,0 }; const int dy[4] = { 0,1,0,-1 }; templateinline void chmax(T&x,T y){if(xinline void chmin(T&x,T y){if(x>y)x=y;} class MillerRabin { using i128 = __int128_t; const vector bases = { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37 }; //intだと、2,7,61で十分 i128 mod_pow(i128 base, i128 exp, ll mod) { i128 ans = 1; base %= mod; while (exp) { if (exp & 1) { ans *= base; ans %= mod; } base *= base; base %= mod; exp >>= 1; } return ans; } public: bool is_prime(ll n) { if (n < 2) { return false; } ll d = n - 1; ll q = 0; while ((d & 1) == 0) { d >>= 1; q++; } for (ll a : bases) { if (a == n) { return true; } if (mod_pow(a, d, n) != 1) { bool flag = true; for (ll r = 0; r < q; r++) { ll pow = mod_pow(a, d * (1ll << r), n); if (pow == n - 1) { flag = false; break; } } if (flag) { return false; } } } return true; } }rho; int main() { int n; cin >> n; while(n--){ ll x; cin >> x; cout << x << ' '; if(rho.is_prime(x))cout << 1 << '\n'; else cout << 0 << '\n'; } }