import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashMap;
public class prog3{
    static HashMap<Long, Integer> freq;
    static int query(long input){
        int ans = 0;
        HashMap<Long, Integer> map = new HashMap<>();
        while(input!=0){
            long q = Long.highestOneBit(input), k = q;
            int val = 1, lim = 0;
            if(freq.containsKey(q))
                lim = (Integer)freq.get(q);
            if(map.containsKey(q))
                val += (Integer)map.get(q);
            while(val>lim){
                k = k>>1;
                if(k == 0)
                    return -1;
                val = (int)(q/k);
                if(map.containsKey(k))
                    val += (Integer)map.get(k);
                lim = 0;
                if(freq.containsKey(k))
                    lim = (Integer)freq.get(k);
            }
            ans += (int)(q/k);
            int orig = 0;
            if(map.containsKey(k))
                orig = (Integer)map.get(k);
            map.put(k, orig+ans);
            
            input = input^q;
        }
        return ans;
    }
    public static void main(String args[])throws IOException{
        InputReader sc = new InputReader(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        
        int n = sc.nextInt(), q = sc.nextInt();
        freq= new HashMap<>();
        while(n-->0){
            long input = sc.nextLong();
            int k = 1;
            if(freq.containsKey(input))
                k += (Integer)freq.get(input);
            freq.put(input, k);
        }
        while(q-->0){
            long input = sc.nextLong();
            pw.println(query(input));
        }
        
        pw.flush();
        pw.close();
    }
    static class InputReader {
        private final InputStream stream;
        private final byte[] buf = new byte[8192];
        private int curChar, snumChars;
        private SpaceCharFilter filter;
 
        public InputReader(InputStream stream) {
            this.stream = stream;
        }
 
        public int snext() {
            if (snumChars == -1)
                throw new InputMismatchException();
            if (curChar >= snumChars) {
                curChar = 0;
                try {
                    snumChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (snumChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }
 
        public int nextInt() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public long nextLong() {
            int c = snext();
            while (isSpaceChar(c)) {
                c = snext();
            }
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = snext();
            }
            long res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = snext();
            } while (!isSpaceChar(c));
            return res * sgn;
        }
 
        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }
 
        private boolean isEndOfLine(int c) {
            return c == '\n' || c == '\r' || c == -1;
        }
 
        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);
        }
    }
}