#include<bits/stdc++.h> using namespace std; const int maxn=1e8+5; int n,q; bool isnp[maxn]; vector<int> primes; void shai(){ for(int i=2;i<=n;i++){ if(!isnp[i]) primes.push_back(i); for(int j=0;j<primes.size();j++){ if(primes[j]*i>n) break; isnp[primes[j]*i]=1; if(i%primes[j]==0) break; } } } int main(){ ios::sync_with_stdio(0); cin>>n>>q; shai(); while(q--){ int x; cin>>x; cout<<primes[x-1]<<endl; } }