# include<iostream>
# include<cstdio>
using namespace std;

const int M=1e8+5;
int n,q,k;
bool v[M];
int p[M/20],cnt=0;

void primes(int n){
	for(int i=2;i<=n;++i){
		if(!v[i]) p[++cnt]=i;
		for(int j=1;j<=cnt&&i*p[j]<=n;++j){
			v[i*p[j]]=1;
			if(i%p[j]==0) break;
		}
	}
}

int main(){
	scanf("%d %d",&n,&q);
	primes(n);
	while(q--){
		scanf("%d",&k);
		printf("%d\n",p[k]);
	}
	return 0;
}