#include <bits/stdc++.h>
const long long mod = 1e9 + 7;
const int maxn = 10000;
using namespace std;
int main() {
  int n, q;
  cin >> n >> q;
  long long a[n];
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  long long arr[31];
  for (int i = 0; i < 31; i++) {
    arr[i] = 0;
  }
  for (int i = 0; i < n; i++) {
    arr[(int)log2(a[i] * 1.0)]++;
  }
  while (q--) {
    long long x;
    cin >> x;
    string ch2 = "";
    while (x != 0) {
      if (x % 2 == 0) {
        ch2 = '0' + ch2;
      } else {
        ch2 = '1' + ch2;
      }
      x /= 2;
    }
    if (ch2.size() == 0) {
      cout << 0 << endl;
    } else {
      bool b;
      bool bol = true;
      long long bj = 0;
      for (long long i = 0; i < ch2.size(); i++) {
        if (ch2[i] == '1') {
          b = false;
          long long cost = 1;
          for (long long j = ch2.size() - i - 1; j > -1; j--) {
            if (arr[j] > 0) {
              b = true;
              bj += cost;
              break;
            } else {
              cost = cost * 2;
            }
          }
          if (!b) {
            bol = false;
            break;
          }
        }
      }
      if (!bol) {
        cout << -1 << endl;
      } else {
        cout << bj << endl;
      }
    }
  }
}
