In a world where timelines are rewritten and alternate realities are just a phone call away, a mad scientist stumbles upon an unusual conundrum.
Imagine two arrays, a_1,\dots, a_n and b_1,\dots, b_m. With each operation, a scientist can pick any pair where 1 \leq i \leq n and 1 \leq j \leq m, and replace a_i with a_i \oplus b_j.
His goal? Minimize the number of distinct elements in array to prevent divergence in the timeline. Each operation brings him closer to stability, but the solution remains elusive.
The first line contains two integers n, m ~(1\le n, m\le 2\cdot 10^5) — the sizes of the arrays and respectively.
The second line contains integers a_1,a_2,\dots, a_n ~(0\le a_i< 2^{30}) — the elements of .
The third line contains integers b_1,b_2,\dots, b_m ~(0\le b_i< 2^{30}) — the elements of .
Output a single integer representing the minimum number of distinct elements in array after performing the allowed operations an arbitrary number of times.
Example 1
In the first sample, we may apply a_1:=a_1\oplus b_3=a_1\oplus 3 = 3 and a_3:=a_3\oplus b_1=3. After that, a=[3, 3, 3, 4] and there are two distinct integers in this modified array. It may be shown that we cannot obtain a smaller answer.
( points): a_i \in \{0, 1\}, ~b_i \in \{0, 1\};
( points): m\le 2;
( points): b_i=2^k;
( points): no additional constraints.