#include<bits/stdc++.h>
#define debug cout<<"debug"
using namespace std;
const int N=1e8+10;
bool v[N];int p[N];
inline int read(){
int x=0;
char ch=getchar();
while(ch>='0'&&ch<='9'){
x=(x<<1)+(x<<3)+(ch^48);
ch=getchar();
}
return x;
}
void os()
{
v[1]=1;
for(int i=2;i<=N;i++)
{
if(!v[i])p[++p[0]]=i;
for(int j=1;j<=p[0]&&i*p[j]<=N;j++)
{
v[i*p[j]] = 1;
if(i%p[j]==0)
break;
}
}
}
int main()
{
int n=read(),q=read(),k;os();
for(int i=1;i<=q;i++){
k=read();
cout<<p[k]<<endl;
}
return 0;
}