B. Array and Permutation
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

Given a permutation $$$p$$$ of length $$$n$$$$$$^{\text{∗}}$$$ and an array $$$a$$$ of length $$$n$$$.

We call the permutation $$$p$$$ generating for the array $$$a$$$ if the array $$$a$$$ can be obtained from the permutation $$$p$$$ by applying some number of operations (possibly zero) of the following type:

Choose an index $$$i$$$ ($$$1 \le i \lt n$$$) and perform one of two replacements:

  • $$$p_{i} := p_{i + 1}$$$;
  • $$$p_{i + 1} := p_{i}$$$.

In other words, in one operation, you can choose two adjacent elements of the array and copy the value of one into the other.

You are required to report whether the permutation $$$p$$$ is generating for the array $$$a$$$.

$$$^{\text{∗}}$$$A permutation of length $$$n$$$ is an array consisting of $$$n$$$ distinct integers from $$$1$$$ to $$$n$$$ in arbitrary order. For example, $$$[2,3,1,5,4]$$$ is a permutation, but $$$[1,2,2]$$$ is not a permutation ($$$2$$$ appears twice in the array), and $$$[1,3,4]$$$ is also not a permutation ($$$n=3$$$ but there is $$$4$$$ in the array).

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 contains a single integer $$$n$$$ ($$$2 \le n \le 2 \cdot 10^{5}$$$) — the length of the array and the permutation.

The second line of each test case contains $$$n$$$ integers $$$p_1, p_2, \ldots, p_n$$$ ($$$1 \le p_{i} \le n$$$) — the elements of the permutation.

The third line of each test case contains $$$n$$$ integers $$$a_1, a_2, \ldots, a_n$$$ ($$$1 \le a_{i} \le n$$$) — the elements of the array.

It is guaranteed that the sum of $$$n$$$ across all test cases does not exceed $$$2 \cdot 10^{5}$$$.

Output

For each test case, output "YES" if the permutation $$$p$$$ is generating for the array $$$a$$$, otherwise output "NO".

You may output each letter in any case (lowercase or uppercase). For example, the strings "yEs", "yes", "Yes", and "YES" will be accepted as a positive answer.

Example
Input
6
3
1 2 3
1 2 2
4
3 1 2 4
3 4 2 2
5
1 3 2 5 4
3 3 3 5 4
7
3 7 4 2 1 6 5
3 3 4 4 5 6 5
7
1 2 3 4 5 6 7
7 7 7 7 7 7 7
7
1 3 2 7 5 4 6
2 2 7 7 7 5 6
Output
YES
NO
YES
NO
YES
YES
Note

In the first test case, the array is generated from the permutation using one operation:

  • $$$i = 2$$$ and $$$p_{i + 1} := p_{i}$$$.

In the second test case, it is impossible to obtain $$$a$$$ from $$$p$$$.

In the third test case, it is necessary to perform $$$2$$$ operations:

  • $$$i = 1$$$ and $$$p_{i} := p_{i + 1}$$$;
  • $$$i = 2$$$ and $$$p_{i + 1} := p_{i}$$$.