import java.util.*;
import java.io.*;
import java.text.*;
import java.math.*;
import static java.lang.Integer.*;
import static java.lang.Double.*;
import java.lang.Math.*;

public class coins {

	public static void main(String[] args) throws Exception {
		new coins().run();
	}
	static long top;
	public void run() throws Exception {
		FastIO file = new FastIO();
		int n = file.nextInt();
		int times = file.nextInt();
		char[] c = new char[32];
		for (int i = 0; i < n; i++) {
			c[(int)( Math.log(file.nextInt()) / Math.log(2))] = '1';
		}
		//System.out.println(Arrays.toString(c));
		while (times-->0) {
			int x = 0;
			int q = file.nextInt();
			if (q % 2 == 1) {
				System.out.println("-1");
				continue;
			}
			else {
				int t = 0;
				String cur = Integer.toBinaryString(q);
				//System.out.println(cur);
				for (int i = cur.length() - 1; i >= 0; i--) {
					if (cur.charAt(i) == '0') continue;
					else {
						int index = cur.length() - i - 1;
						int count = 1;
						while (c[index] != '1') {
							index >>= 1;
							count <<= 1;
						}
						//System.out.println(count);
						t += Math.pow(2, index) * count;
						x += count;
					}
				}
				System.out.println(t == q ? x : -1);
			}
		}
	}

	public static class FastIO {
		BufferedReader br;
		StringTokenizer st;

		public FastIO() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st == null || !st.hasMoreElements()) {
				try {
					st = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			}
			return st.nextToken();
		}

		int nextInt() {
			return Integer.parseInt(next());
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}

		String nextLine() {
			String str = "";
			try {
				str = br.readLine();
			} catch (IOException e) {
				e.printStackTrace();
			}
			return str;
		}
	}

	public static long pow(long n, long p, long mod) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n % mod;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2, mod);
			return (temp * temp) % mod;
		} else {
			long temp = pow(n, p / 2, mod);
			temp = (temp * temp) % mod;
			return (temp * n) % mod;

		}
	}

	public static long pow(long n, long p) {
		if (p == 0)
			return 1;
		if (p == 1)
			return n;
		if (p % 2 == 0) {
			long temp = pow(n, p / 2);
			return (temp * temp);
		} else {
			long temp = pow(n, p / 2);
			temp = (temp * temp);
			return (temp * n);

		}
	}

	public static long gcd(long x, long y) {
		if (x == 0)
			return y;
		else
			return gcd(y % x, x);
	}

	public static boolean isPrime(int n) {
		if (n <= 1)
			return false;
		if (n <= 3)
			return true;

		if (n % 2 == 0 || n % 3 == 0)
			return false;

		for (int i = 5; i * i <= n; i = i + 6)
			if (n % i == 0 || n % (i + 2) == 0)
				return false;

		return true;
	}

}