#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
  long long n, q, x;
  cin >> n >> q;
  long long cnt[50] = {0};
  for (int i = 0; i < n; i++) {
    cin >> x;
    long long temp = log2(x);
    cnt[temp]++;
  }
  for (int i = 0; i < q; i++) {
    long long qe;
    cin >> qe;
    long long cntb[50];
    for (int j = 0; j < 50; j++) cntb[j] = cnt[j];
    vector<long long> v;
    while (qe) {
      v.push_back(qe % 2);
      qe /= 2;
    }
    long long sz = v.size();
    long long possible = 1, coins = 0;
    for (int j = 0; j < sz; j++) {
      if (v[j]) {
        long long found = 0, it = 0, taken = j, add;
        while (found == 0 && taken >= 0) {
          if (cntb[taken] >= pow(2, it)) {
            cntb[taken] -= pow(2, it);
            found = 1;
            coins += pow(2, it);
            break;
          } else {
            it++;
            taken--;
          }
        }
        if (found == 0) {
          possible = 0;
          break;
        }
      }
    }
    if (possible)
      cout << coins << "\n";
    else
      cout << -1 << "\n";
  }
  return 0;
}
