import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author bacali
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DCoinsAndQueries solver = new DCoinsAndQueries();
        solver.solve(1, in, out);
        out.close();
    }

    static class DCoinsAndQueries {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int q = in.nextInt();
            int[] occ = new int[32];
            for (int i = 0; i < n; i++) {
                occ[log2(in.nextInt())]++;
            }
            for (int i = 0; i < q; i++) {
                int b = in.nextInt();
                char[] ch = Integer.toBinaryString(b).toCharArray();
                int[] occAux = occ.clone();
                int bb = 0;
                int min = 0;
                boolean ok = true;
                for (int j = ch.length - 1; j > -1; j--) {
                    if (ch[j] == '1') {
                        int dh = 1;
                        int k = 0;
                        while (k <= bb && occAux[bb - k] < dh) {
                            k++;
                            dh *= 2;
                        }
                        if (k == bb + 1) {
                            out.println(-1);
                            ok = false;
                            break;
                        }
                        occAux[bb - k] -= dh;
                        min += dh;
                    }
                    bb++;
                }
                if (ok) {
                    out.println(min);
                }
            }
        }

        public int log2(int a) {
            return (int) (Math.log(a) / Math.log(2));
        }

    }

    static class FastScanner {
        private BufferedReader br;
        private StringTokenizer st;

        public FastScanner(InputStream inputStream) {
            br = new BufferedReader(new InputStreamReader(inputStream));
        }

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

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

    }
}

