from random import randint def miller_rabin(n, rep=5): if n == 2: return True if n == 1 or n % 2 == 0: return False d = n - 1 r = (d & -d).bit_length() - 1 d >>= r for k in range(rep): a = 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 *= 2 if y != n - 1 and t % 2 == 0: return False return True n = int(input()) for i in range(n): a = int(input()) b = int(miller_rabin(n)) print(a, b)