#include <bits/stdc++.h>
using namespace std;
const int N = 1e8+3;
bool pri[N];
int f[N];//存放素数
void ola(int x)//欧拉筛核心代码
{
int k = 0;
for (int i = 2; i <= x; i++)
{
if (!pri[i])
f[++k] = i;//存入数组中
for (int j = 1; f[j] * i <= x; j++)
{
pri[f[j] * i] = 1;
if (i % f[j] == 0)//跳出循环条件
break;
}
}
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int n, q;
cin >> n >> q;
ola(n);
while(q--)
{
int k;
cin>>k;
cout<<f[k]<<'\n';
}
return 0;
}