n = int(input())
def helper(n):
i = 2
## 这里要是n != 1 就会TLE,因为有可能有个大质数因数
while i*i <= n:
if n % i == 0:
ct = 0
while n % i == 0:
n //= i
ct += 1
print(str(i) + " " + str(ct))
i += 1
if n != 1:
print(str(n) + " 1" )
for _ in range(n):
m = int(input())
helper(m)
print()