#P11209. Bitwise XOR Condition Count

    ID: 13276 Type: Default 1000ms 256MiB

Bitwise XOR Condition Count

Bitwise XOR Condition Count

Given two sequences \(\{a_i\}_{i=1}^n\) and \(\{b_i\}_{i=1}^n\), process \(m\) queries. In each query, you are given an integer \(k\). For each query, compute the following sum:

[ S = \sum_{i=1}^n \bigl[ (a_i \oplus k) \le b_i \bigr] ]

Here, \(\oplus\) is the bitwise XOR operator, and \([P]\) denotes the Iverson bracket, which equals 1 if the predicate \(P\) is true and 0 otherwise.

Note: Some of the test cases are evaluated online.

inputFormat

The first line contains two integers \(n\) and \(m\) (\(1 \le n, m \le 10^5\) or appropriate limits as specified by the problem).

The second line contains \(n\) integers representing the sequence \(a_1, a_2, \dots, a_n\).

The third line contains \(n\) integers representing the sequence \(b_1, b_2, \dots, b_n\).

Then \(m\) lines follow, each containing one integer \(k\), representing a query.

outputFormat

For each query, output a single integer on a new line, the value of \(S = \sum_{i=1}^n \bigl[ (a_i \oplus k) \le b_i \bigr]\).

sample

5 3
1 2 3 4 5
5 4 3 2 1
1
2
3
3

3 3

</p>