#include <iostream>
#include <cstdio>
usingnamespace std;
typedef longlong ll;
constint N=1e7+100;
int m,q;
int p[N/100],mx[N],f[N];
void Prime()
for (int i=1;i<=m;i++)
for (int j=1;j<=(N-100)/p[i];j++)
mx[j*p[i]]=p[i];
int main()
scanf("%d%d",&m,&q);
for (int i=1;i<=m;i++) scanf("%d",&p[i]);
Prime();mx[0]=p[m];
for (int l=0,r=1;l<r&&r<=N-100;l++)
if (!mx[l]) continue;
for (;r<=min(l+mx[l]-1,N-100);) f[r++]=f[l]+1;
for (;q;q--)
int qq;
scanf("%d",&qq);
printf((f[qq]?"%d\n":"oo\n"),f[qq]);