| ASU Coding Cup 10 |
|---|
| Закончено |
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$$$.
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.
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.
For each test case, print the answer.
25 31 2 3 4 55 7 25 11 2 3 4 57
3 0
| Название |
|---|


