Universal Cup Judging System

Universal Cup

Time Limit: 2.0 s Memory Limit: 1024 MB Total points: 100 Hackable ✓
Statistics

Data una sequenza di interi di lunghezza $n$ ($n \ge 2$), indicata con $a_{1,2,\ldots,n}$, e una sequenza di interi di lunghezza $m$ ($m \ge 2$), indicata con $b_{1,2,\ldots,m}$, possiamo costruire una matrice $c$ di dimensione $n \times m$ tale che $c_{i,j} = a_i \oplus b_j$ ($1 \le i \le n, 1 \le j \le m$), dove $\oplus$ indica l'operazione XOR bit a bit.

Determina quante coppie $(i, j)$ ($1 \le i < n, 1 \le j < m$) soddisfano la condizione per cui la regione sottorettangolare di $c$ data da $\begin{bmatrix} c_{i,j} & c_{i,j+1} \\ c_{i+1,j} & c_{i+1,j+1} \end{bmatrix}$ è della forma $\begin{bmatrix} x & x + 1 \\ x + 2 & x + 3 \end{bmatrix}$, ovvero $c_{i,j+1} = c_{i,j} + 1$, $c_{i+1,j} = c_{i,j} + 2$ e $c_{i+1,j+1} = c_{i,j} + 3$.

Input

La prima riga contiene un intero $T$ ($1 \le T \le 10^5$), che rappresenta il numero di casi di test.

Per ogni caso di test:

La prima riga contiene due interi separati da spazio $n, m$ ($2 \le n, m \le 2 \times 10^5$), che rappresentano il numero di righe e di colonne di $c$.

La seconda riga contiene $n$ interi separati da spazio, che rappresentano $a_1, a_2, \ldots, a_n$ ($0 \le a_i < 2^{30}$).

La terza riga contiene $m$ interi separati da spazio, che rappresentano $b_1, b_2, \ldots, b_m$ ($0 \le b_i < 2^{30}$).

È garantito che la somma di $n$ non superi $2 \times 10^5$ e che la somma di $m$ non superi $2 \times 10^5$.

Output

Per ogni caso di test, stampa una singola riga contenente un intero, che rappresenta quante coppie $(i, j)$ soddisfano la condizione.

Esempi

Input 1

5
2 2
0 2
0 1
3 3
6 4 2
6 7 10
5 4
4 6 5 1 3
1 0 2 3
7 2
7 3 1 4 0 0 1
6 5
5 5
1 7 5 3 1
3 2 7 7 6

Output 1

1
2
1
0
6

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.