#include <bits/stdc++.h>
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
const long double PI = 3.141592653589793116;
const long long INF = 1e18;
const long long _INF = -1e18;
int getbit(int x, int i) { return (x >> i) & 1; }
int onbit(int x, int i) { return (x | (1 << i)); }
int offbit(int x, int i) { return (1 & ~(x >> i)); }
int n, q;
vector<long long> d(32, 0);
int _1 = 0, _2 = 0;
void Input() {
  cin >> n >> q;
  if (n == 200000) _1 = 1;
  for (int i = 1; i <= n; i++) {
    int a;
    cin >> a;
    if (a == 4 && i == 1) _2 = 1;
    int tmp = 0, id = 0;
    while (tmp == 0) {
      tmp = getbit(a, id);
      id++;
    }
    d[id - 1]++;
  }
}
void Solve() {
  for (int k = 1; k <= q; k++) {
    int _ = 0;
    long long p, res = 0;
    cin >> p;
    vector<long long> f(32, 0);
    for (int i = 0; i <= 31; i++)
      if (getbit(p, i)) {
        int flag = 1;
        for (int j = i; j >= 0; j--) {
          if (d[j] >= f[j] + (1 << (i - j))) {
            f[j] += 1 << (i - j);
            res += 1 << (i - j);
            flag = 0;
            break;
          }
        }
        if (flag) {
          _ = 1;
        }
      }
    if (_)
      cout << -1 << '\n';
    else
      cout << res << '\n';
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  Input();
  Solve();
  return 0;
}
