#y1498 def E_sieve(n): Primes = [] if n > 1: Primes.append(2) l = (n-1)//2 Flag = [True]*l for i in range(l): p = 2*i+3 if not Flag[i]: continue Primes.append(p) for i in range((p*p-3)//2, l, p): Flag[i] = False return Primes P = E_sieve(100001) Memo = {} for _ in range(int(input())): q = int(input()) if Memo.get(q, 0): Ans = Memo[q] else: Ans = [] x = q**2+1 if q&1: x //= 2 Ans.append(2) for p in P: if p**2 > x: break if not x%p: while not x%p: Ans.append(p) x //= p if x > 1: Ans.append(x) Memo[q] = Ans print(*Ans)