import java.io.*; import java.util.*; import java.util.function.*; import java.util.stream.*; public class Main { public static void main(String[] args) throws Exception { Scanner sc = new Scanner(); int n = sc.nextInt(); int q = sc.nextInt(); int[] values = new int[n]; for (int i = 0; i < n; i++) { values[i] = sc.nextInt(); } char[] bits = sc.next().toCharArray(); long[][] scores = new long[30][2]; for (int i = 0; i < 30; i++) { for (int j = 0; j < 2; j++) { int x = j; for (int k = 0; k < n; k++) { if (x == 0 && (values[k] & (1 << i)) > 0 && bits[k] == '1') { x = 1; scores[i][j] += (1 << i); } else if (x == 1 && (values[k] & (1 << i)) == 0 && bits[k] == '0') { x = 0; scores[i][j] += (1 << i); } } } } String result = IntStream.range(0, q).mapToObj(s -> { int x = sc.nextInt(); long ans = 0; for (int i = 0; i < 30; i++) { ans += scores[i][(x & (1 << i)) == 0 ? 0 : 1]; } return String.valueOf(ans); }).collect(Collectors.joining("\n")); System.out.println(result); } } class Scanner { BufferedReader br; StringTokenizer st = new StringTokenizer(""); StringBuilder sb = new StringBuilder(); public Scanner() { try { br = new BufferedReader(new InputStreamReader(System.in)); } catch (Exception e) { } } public int nextInt() { return Integer.parseInt(next()); } public long nextLong() { return Long.parseLong(next()); } public double nextDouble() { return Double.parseDouble(next()); } public String next() { try { while (!st.hasMoreTokens()) { st = new StringTokenizer(br.readLine()); } } catch (Exception e) { e.printStackTrace(); } finally { return st.nextToken(); } } }