The first line of the input contains an integer $T(1\leq T\leq 3)$, denoting the number of test cases.
In each test case, there is one integer $n(1\leq n\leq 50000)$ in the first line, denoting the size of permutation.
In the second line, there are $n$ distinct integers $p_1,p_2,...,p_n(1\leq p_i\leq n)$, denoting the permutation.
In the third line, there are $n$ distinct integers $k_1,k_2,...,k_n(1\leq k_i\leq n)$, describing each stage.
It is guaranteed that $p_1,p_2,...,p_n$ and $k_1,k_2,...,k_n$ are generated randomly.