import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int q = sc.nextInt(); long[][] dp = new long[31][2]; int[][] values = new int[31][2]; for (int i = 0; i < 31; i++) { values[i][1] = 1; } int[] vArr = new int[n]; for (int i = 0; i < n; i++) { vArr[i] = sc.nextInt(); } char[] arr = sc.next().toCharArray(); for (int i = 0; i < n; i++) { int a = vArr[i]; for (int j = 0; j < 31; j++) { int bit = a % 2; a /= 2; for (int k = 0; k < 2; k++) { if (bit == 1 && values[j][k] == 0 && arr[i] == '1') { values[j][k] = 1; dp[j][k] += (1 << j); } else if (bit == 0 && values[j][k] == 1 && arr[i] == '0') { values[j][k] = 0; dp[j][k] += (1 << j); } } } } StringBuilder sb = new StringBuilder(); for (int i = 0; i < q; i++) { int t = sc.nextInt(); long ans = 0; for (int j = 0; j < 31; j++) { ans += dp[j][t % 2]; t /= 2; } sb.append(ans).append("\n"); } System.out.print(sb); } }