def miller_rabin(x: int): if x == 2: return 1 if x < 2 or (x & 1) == 0: return 0 for a in [2,325,9375,28178,450775,9780504,1795265022]: if a % x == 0: continue d = x - 1 s = 0 while (d & 1) == 0: d //= 2 s += 1 t = pow(a, d, x) if t == 1: continue for _ in range(s): if t == (x - 1): break t = pow(t, 2, x) else: # breakでループを抜けなかった時 return 0 continue return 1 n = int(input()) for _ in range(n): x = int(input()) print(x,miller_rabin(x))