//Find all prime number that is less than N

t=int(input())
for i in range(t):
    n=int(input())    //value of N
    prime=[True for i in range(n+1)]
    p=2
    while(p*p<=n):
        if(prime[p]==True):
            for j in range(p*p,n+1,p):
                prime[j]=False
        p+=1
    
    for k in range(2,n+1):
        if(prime[k]==True):
            print(k,end=" ")
    print()