I. Colorful Queries
time limit per test
1 second
memory limit per test
512 megabytes
input
standard input
output
standard output

You have $$$n$$$ items in a vertical stack, the color of the $$$i$$$-th item from the top is $$$c_i$$$.

You need to process $$$q$$$ queries on this stack. In each query, you'll be given a color $$$d$$$ and you need to —

  • Find the top-most item of color $$$d$$$ in the current stack and print its position from the top of the stack.
  • And then, move this item to the top of the stack.
Input

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

The first line of each test case contains two integers $$$n$$$ and $$$q$$$ ($$$1 \le n \le 10^5$$$; $$$1 \le q \le 10^5$$$) — the number of items in the stack and the number of queries.

The second line of each test case contains $$$n$$$ integers $$$c_1, c_2, \dots, c_n$$$ ($$$1 \le c_i \le n$$$) — colors of the items.

The third line of each test case contains $$$q$$$ integers $$$d_1, d_2, \dots, d_q$$$ ($$$1 \le d_i \le n$$$) — colors in the queries.

It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$10^5$$$ and the sum of $$$q$$$ doesn't exceed $$$10^5$$$. Also, for every $$$d_i$$$ in the queries, there is at least one item in the stack with color $$$d_i$$$.

Output

For each test case, output $$$q$$$ lines containing the answers to the corresponding queries.

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