D. Distinct Game
time limit per test
2 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Given two arrays $$$a_1, a_2, \dots, a_n$$$ and $$$b_1, b_2, \dots, b_m$$$ such that $$$n+m=2k$$$. All values of both arrays are from $$$1$$$ to $$$k$$$. Every value from $$$1$$$ to $$$k$$$ appears exactly twice in arrays, both occurrences could be either in the same array or in different ones.

Two players play a game. In each move, the player can take the last element of either array. The game ends when all elements are taken. The second player wins if all his elements are distinct, otherwise, the first player wins. Determine which player has a winning strategy.

Input

The first line contains a single integer $$$t$$$ ($$$1 \le t \le 10^5$$$)  — the number of test cases. The description of test cases follows.

The first line of each test case contains two integers $$$n$$$ and $$$m$$$ ($$$1 \leq n, m \leq 5\cdot 10^5$$$)  — the length of the arrays.

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \leq a_i \leq {{n+m} \over 2}$$$)  — elements of the first array.

The second line of each test case contains $$$m$$$ integers $$$b_1, b_2, \ldots, b_m$$$ ($$$1 \leq b_i \leq {{n+m} \over 2}$$$)  — elements of the second array.

Each value from 1 to $$${n+m} \over 2$$$ appears exactly twice in the arrays.

It is guaranteed that the sum of $$$n+m$$$ over all test cases does not exceed $$$10^6$$$.

Output

For each test case, print 1 if the first player wins and 2 otherwise.

Example
Input
4
1 3
1
1 2 2
3 3
1 2 3
2 3 1
2 4
3 1
2 3 1 2
2 2
1 2
1 2
Output
2
1
2
2