#include <bits/stdc++.h>
using namespace std;
const int max2=5000002;
const int maxn=86028127;
bool p[maxn]={false};
int a[max2];
int m1,m;
void nt(){
int gt=sqrt(maxn);
for (int i=3 ; i<=gt ; i+=2) if (p[i]==false) {
for (int j=i*i ; j<=maxn ; j+=i){
p[j]=true;
}
}
m1=1;
a[m1]=2;
for (int i=3; i<=maxn; i++){
if (p[i]==false && i%2==1){
m1++;
a[m1]=i;
}
}
}
int main()
{
nt();
int t,x;
scanf("%d",&t);
for (int i=1; i<=t; i++){
scanf("%d",&x);
printf("%d\n",a[x]);
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwpjb25zdCBpbnQgbWF4Mj01MDAwMDAyOwpjb25zdCBpbnQgbWF4bj04NjAyODEyNzsKYm9vbCBwW21heG5dPXtmYWxzZX07CmludCBhW21heDJdOwppbnQgbTEsbTsKdm9pZCBudCgpewogICAgaW50IGd0PXNxcnQobWF4bik7CiAgICBmb3IgKGludCBpPTMgOyBpPD1ndCA7IGkrPTIpIGlmIChwW2ldPT1mYWxzZSkgewogICAgICAgICBmb3IgKGludCBqPWkqaSA7IGo8PW1heG4gOyBqKz1pKXsKICAgICAgICAgICAgICAgIHBbal09dHJ1ZTsKICAgICAgICAgfQogICAgfQogICAgbTE9MTsKICAgIGFbbTFdPTI7CiAgICBmb3IgKGludCBpPTM7IGk8PW1heG47IGkrKyl7CiAgICAgICAgaWYgKHBbaV09PWZhbHNlICYmIGklMj09MSl7CiAgICAgICAgICAgICBtMSsrOwogICAgICAgICAgICAgYVttMV09aTsKICAgICAgICAgICAgfQogICAgfQp9CmludCBtYWluKCkKewogICAgbnQoKTsKICAgIGludCB0LHg7CiAgICBzY2FuZigiJWQiLCZ0KTsKICAgIGZvciAoaW50IGk9MTsgaTw9dDsgaSsrKXsKICAgICAgICBzY2FuZigiJWQiLCZ4KTsKICAgICAgICBwcmludGYoIiVkXG4iLGFbeF0pOwogICAgfQogICAgcmV0dXJuIDA7Cn0K