import random from sys import stdin, stdout def main(): N = int(input()) X = map(int, stdin.read().splitlines()) for i in X: stdout.write(str(i) + ' ') stdout.write(str(int(is_prime(i))) + '\n') def is_prime(n): if n == 2: return True if n == 1 or not n % 2: return False d = (n - 1) >> 1 while not d % 2: d >>= 1 for k in range(100): a = random.randint(1, n - 1) t = d y = pow(a, t, n) while t != n - 1 and y != 1 and y != n - 1: y = (y * y) % n t <<= 1 if y != n - 1 and not t % 2: return False return True input = lambda: stdin.readline() main()