|시간 제한||메모리 제한||제출||정답||맞은 사람||정답 비율|
|2 초||512 MB||0||0||0||0.000%|
Andorra is a horizontal city that consists of a set of side-by-side blocks. Each block has a number corresponding to its type and multiple blocks can have the same type.
Andy is the contractor of Andorra. From experience, when Andy meets an investor he usually knows what type of blocks he will be interested in buying. Showing the investor only that type will be very obvious and might make the investor negotiate and reduce the price.
Andy, being the smart guy he is, makes a tour for the investor, the tour could be one block, or multiple consecutive blocks, and the tour should contain at least one block of the type the investor wants. After the tour, Andy manages to sell all blocks of that type to the investor. A tour can not include blocks that have been sold before, otherwise owners will be upset.
Andy has a series of investor coming his way and he will deal with them in the order of their arrival. He needs your help in planning. For each investor he wants to know;
Your program will be tested on one or more test cases. The first line of the input will be a single integer T (1 ≤ T ≤ 100).
Each test case starts with a line that contains two space separated integers:
Followed by 2 lines. The first line contains N space separated integers, each integer x represents the type of block i. The second line contains Q space separated integers, each integer y represents the block type that investor j is interested in. (1 ≤ x, y ≤ 1, 000, 000, 000).
For each test case, print Q lines each containing 2 space separated integers. Each line j contains 2 space separated integers, the number of tours possible for investor j and the number of future tours possible being done with that investor respectively.
1 2 2 1 2 1 2
2 1 1 0
Notes: In the test case, Andorra has 2 block. In the beginning, they are all free so Andy can give 3 tours: