Distinct Game#12936

Distinct Game

2 seconds
256 megabytes
Medium

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 to . Every value from to 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 (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 and (1 \leq n, m \leq 5\cdot 10^5)  — the length of the arrays.

The second line of each test case contains 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 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.

Examples

Example

Loading
Loading