#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
#define n 163842
int main()
{
int a[81922];
int i,j,s,count,k,t;
cin>>t;
while(t--)
{
count=0;
cin>>k;
for(i=2;i<n>>1;i++)
a[i]=0;
s=int(sqrt((double )n));
///cout<<s;
for(i=3;i<=s;i+=2)
{
if(a[i>>1]==0)
{
for( j = i * i; j <= n; j += i + i )
{
a[j>>1]=1;
}
}
}
//cout<<2;
if(k==1)
cout<<2<<endl;
for(i=3;i<=n;i+=2)
{
if(a[i>>1]==0)
{
///cout<<"prime="<<i<<endl;
count++;
if(count==k-1)
{
cout<<i<<endl;
break;
}
}
}
//cout<<count;
}
}
I2luY2x1ZGU8aW9zdHJlYW0+CiNpbmNsdWRlPGNzdGRpbz4KI2luY2x1ZGU8Y21hdGg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CiNkZWZpbmUgICAgIG4gMTYzODQyCmludCBtYWluKCkKewogICAgaW50IGFbODE5MjJdOwogICAgaW50IGksaixzLGNvdW50LGssdDsKICAgIGNpbj4+dDsKICAgIHdoaWxlKHQtLSkKICAgIHsKICAgICAgICBjb3VudD0wOwogICAgICAgICBjaW4+Pms7CiAgICBmb3IoaT0yO2k8bj4+MTtpKyspCiAgICAgICAgYVtpXT0wOwogICAgcz1pbnQoc3FydCgoZG91YmxlICluKSk7CiAgICAvLy9jb3V0PDxzOwogICAgZm9yKGk9MztpPD1zO2krPTIpCiAgICB7CiAgICAgICAgaWYoYVtpPj4xXT09MCkKICAgICAgICB7CiAgICAgICAgICAgIGZvciggaiA9IGkgKiBpOyBqIDw9IG47IGogKz0gaSArIGkgKQoKICAgICAgICAgICAgewogICAgICAgICAgICAgICAgYVtqPj4xXT0xOwogICAgICAgICAgICB9CiAgICAgICAgfQogICAgfQogICAgLy9jb3V0PDwyOwogICAgaWYoaz09MSkKICAgICAgICBjb3V0PDwyPDxlbmRsOwogICAgICAgIGZvcihpPTM7aTw9bjtpKz0yKQogICAgewogICAgICAgIGlmKGFbaT4+MV09PTApCiAgICAgICAgewogICAgICAgICAgIC8vL2NvdXQ8PCJwcmltZT0iPDxpPDxlbmRsOwoKICAgICAgICAgICBjb3VudCsrOwogICAgICAgICAgIGlmKGNvdW50PT1rLTEpCiAgICAgICAgICAgewogICAgICAgICAgICAgICBjb3V0PDxpPDxlbmRsOwogICAgICAgICAgICAgICBicmVhazsKICAgICAgICAgICB9CiAgICAgICAgfQoKCiAgICB9CiAgICAvL2NvdXQ8PGNvdW50OwoKCiAgICB9Cgp9Cg==