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[] inputs = sc.next().toCharArray(); long[][] scores = new long[30][2]; boolean[][] current = new boolean[2][30]; Arrays.fill(current[1], true); for (int i = 0; i < n; i++) { boolean isAnd = inputs[i] == '0'; for (int j = 0; j < 30; j++) { boolean isTrue = (values[i] & (1 << j)) > 0; for (int k = 0; k < 2; k++) { if ((isAnd && current[k][j] && !isTrue) || (!isAnd && !current[k][j] && isTrue)) { scores[j][k] += (1 << j); current[k][j] ^= true; } } } } String result = IntStream.range(0, q).mapToObj(b -> { int x = sc.nextInt(); long ans = 0; for (int i = 0; i < 30; i++) { ans += scores[i][x % 2]; x >>= 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(); } } }