#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
int N = 163842, status[163842]= {0};
int main()
{
int i, j, sqrtN,count,k,t;
cin>>t;
while(t--)
{
cin>>k;
count=0;
sqrtN = int ( sqrt((double) N ));
for( i = 3; i <= sqrtN; i += 2 )
{
if( status[i] == 0 )
{
for( j = i * i; j <= N; j += i )
{
status[j] = 1;
}
}
}
if(k==1)
cout<<2<<endl;
else
{
for( i = 3; i <= N; i += 2 )
{
if(status[i]==0)
{
count++;
if(count==k-1)
{
cout<<i<<endl;
break;
}
}
}
}
}
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNtYXRoPgojaW5jbHVkZTxjc3RkaW8+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CmludCBOID0gMTYzODQyLCBzdGF0dXNbMTYzODQyXT0gezB9OwppbnQgbWFpbigpCnsKICAgIGludCAgaSwgaiwgc3FydE4sY291bnQsayx0OwogICAgY2luPj50OwogICAgd2hpbGUodC0tKQogICAgewogICAgY2luPj5rOwogICAgY291bnQ9MDsKICAgIHNxcnROID0gaW50ICggc3FydCgoZG91YmxlKSBOICkpOwogICAgZm9yKCBpID0gMzsgaSA8PSBzcXJ0TjsgaSArPSAyICkKICAgIHsKICAgICAgICBpZiggc3RhdHVzW2ldID09IDAgKQogICAgICAgIHsKICAgICAgICAgICAgZm9yKCBqID0gaSAqIGk7IGogPD0gTjsgaiArPSBpICkKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgc3RhdHVzW2pdID0gMTsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgIH0KICAgIGlmKGs9PTEpCiAgICBjb3V0PDwyPDxlbmRsOwogICAgZWxzZQogICAgewogICAgZm9yKCBpID0gMzsgaSA8PSBOOyBpICs9IDIgKQogICAgewogICAgICAgIGlmKHN0YXR1c1tpXT09MCkKICAgICAgICB7CiAgICAgICAgICAgIGNvdW50Kys7CiAgICAgICAgICAgIGlmKGNvdW50PT1rLTEpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQ8PGk8PGVuZGw7CiAgICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICAgfQogICAgICAgICAgICAKICAgICAgICB9CiAgICB9CiAgICB9CiAgICAKICAgIH0KfQ==