T = int(input())
X = []
maximum = 0
for i in range(T):
    tau = int(input())
    X.append(tau)
    if tau>maximum:
        maximum = tau

#Sieve of Eratostenes
prime = [True for i in range(maximum)]
primes = []
p = 2
while (p * p <= maximum):
    if (prime[p]):
        primes.append(p)
        for i in range(p * 2, maximum, p):
            prime[i] = False
    p += 1
while (p<=maximum/2):
    if (prime[p]):
        primes.append(p)
    p += 1

prime[0] = False
prime[1] = False

for j in range(T):
    i=0
    q = X[j]-primes[i]
    while not (prime[q]):
        i+=1
        q = X[j] - primes[i]
    print(str(primes[i])+" "+str(q))