The first line of the input is a positive integer $t$, denoting the number of test cases.
Then follows $t$ test cases, each test case starts with space-separated integers $n$, $m$, $p$ ($1 \le n, m \le 10^5$, $p \in \{1, 2\}$). Generally speaking, this should be followed by two lines of integers $a_1, a_2, \ldots, a_n$ and $b_1, b_2, \ldots, b_m$, denoting the colors of Cuber QQ's hand and Quber CC's hand, respectively. Unfortunately, as it turns out, the input will be the bottleneck in that case. So we introduce $p$ to deal with this problem.
For $p = 1$, there follows two lines, where the first line is $a_1, a_2, \ldots, a_n$ and the second line is $b_1, b_2, \ldots, b_m$, all space separated and $0 \le a_i, b_i < 10^9$.
For $p = 2$, there follows two lines, which are $k_1, k_2, mod$ ($0 \le k_1, k_2 < 2^{64}$, $1 \le mod \le 10^9$) to generate $\{a_i\}$ and $\{b_i\}$, respectively.
Here are some instructions on how to generate $\{a_i\}$, $\{b_i\}$ with $k_1, k_2, mod$, which you've probably seen before, somehow:
unsigned long long k1, k2;
unsigned long long rng() {
unsigned long long k3 = k1, k4 = k2;
k1 = k4;
k3 ^= k3 << 23;
k2 = k3 ^ k4 ^ (k3 >> 17) ^ (k4 >> 26);
return k2 + k4;
}
// generate
read(k1, k2, mod);
for (int i = 0; i < n; ++i)
a[i] = rng() % mod;
read(k1, k2, mod);
for (int i = 0; i < m; ++i)
b[i] = rng() % mod;
Also, the sum of $n+m$ for $p=1$ does not exceed $5 \cdot 10^5$; the sum of $n+m$ from all test cases does not exceed $10^7$.