#include <bits/stdc++.h>
using namespace std;
bool checkbit(unsigned int n, unsigned int p) {
  unsigned int m = 1 << p;
  return n & m;
}
signed main() {
  unsigned int i, j, k, n, q, p;
  scanf("%d %d", &n, &q);
  map<unsigned int, unsigned int> mpp;
  k = 30;
  p = 1;
  mpp[1] = 0;
  for (i = 2; i <= 32; i++) {
    p = p * 2;
    mpp[p] = i - 1;
  }
  unsigned int vis[33], arr[33];
  memset(vis, 0, sizeof(vis));
  while (n--) {
    scanf("%d", &k);
    p = mpp[k];
    vis[p]++;
  }
  bool ok;
  unsigned int cnt;
  while (q--) {
    scanf("%d", &k);
    cnt = 0;
    for (i = 0; i < 32; i++) {
      arr[i] = vis[i];
    }
    for (i = 31;; i--) {
      if (checkbit(k, i)) {
        p = 1;
        ok = 0;
        for (j = i;; j--) {
          if (arr[j] >= p) {
            ok = 1;
            break;
          }
          if (!j) break;
          p = p * 2;
        }
        cnt += p;
        if (!ok) {
          cnt = 0;
          printf("-1\n");
          break;
        }
      }
      if (!i) break;
    }
    if (cnt) printf("%d\n", cnt);
  }
  return 0;
}
