L. The Elephant and the Array
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

In ASZoo, the elephant wants to solve an interesting problem.

Given an array $$$a$$$ of length $$$n$$$ and array $$$b$$$ of length $$$m$$$, ($$$b$$$ values are unique).

The elephant wants to do the following operations until no element in $$$a$$$ exists in $$$b$$$.

  • In the first operation, the elephant deletes the first element of the array.
  • In the second operation, the elephant deletes the last element of the array ($$$a_n$$$).
  • In the third operation, the elephant deletes the second element of the array ($$$a_2$$$).

And he keeps doing the same operation until the condition is met or the array becomes empty.

More formally, in the operation $$$i$$$ where ($$$i \equiv 1 (mod 2)$$$), the elephant deletes the element at the beginning of the array.

And in operation ($$$i \equiv 0 (mod 2)$$$), the elephant deletes the element at the end of the array.

Calculate the minimum number of operations to meet the condition.

Input

Each test contains multiple test cases. The first line contains the number of test cases $$$t$$$ ($$$1 \le t \le 10^4$$$). The description of the test cases follows.

The first line of each test case consists of two integers $$$n$$$ and $$$m$$$ ($$$1 \le n, m \le 2 \cdot 10^5$$$).

The second line of each test case consists of $$$n$$$ integers $$$a_1, a_2, ..., a_n$$$ ($$$1 \le a_i \le 10^6$$$).

The third line of each test case consists of $$$m$$$ integers $$$b_1, b_2, ..., b_n$$$ ($$$1 \le b_i \le 10^6$$$).

The sum of $$$n$$$ and $$$m$$$ doesn't exceed $$$2 \cdot 10^5$$$ over all test cases.

Output

For each test case, print the answer.

Example
Input
2
5 3
1 2 3 4 5
5 7 2
5 1
1 2 3 4 5
7
Output
3
0