#include <bits/stdc++.h>
using namespace std;
int const N = 2e5 + 1;
int n, q, a[N], fr[35];
int main() {
  scanf("%d %d", &n, &q);
  for (int i = 0; i < n; ++i) {
    scanf("%d", a + i);
    bitset<32> bs(a[i]);
    for (int i = 0; i < 32; ++i)
      if (bs[i] == 1) ++fr[i];
  }
  while (q-- != 0) {
    int tmp;
    scanf("%d", &tmp);
    bitset<32> bs(tmp);
    int cnt = 0;
    bool ok = true;
    for (int i = 0; i < 32; ++i) {
      if (bs[i] == 1) {
        ++cnt;
        if (fr[i] == 0) {
          ok = false;
          break;
        }
      }
    }
    if (ok)
      printf("%d\n", cnt);
    else
      puts("-1");
  }
  return 0;
}
