F. Pull Smaller
time limit per test
1.5 seconds
memory limit per test
256 megabytes
input
standard input
output
standard output

You are given an array $$$a$$$ of $$$n$$$ integers.

Let's define an operation on $$$a$$$ as follows:

  • Pick two indices $$$i$$$ and $$$j$$$ such that $$$1 \le i \lt j \le n$$$ and $$$a_i \gt a_j$$$.
  • Place the element $$$a_j$$$ right before $$$a_i$$$  — that is in-between $$$a_{i-1}$$$ and $$$a_i$$$ if $$$i \gt 1$$$ and before the first element if $$$i = 1$$$.

For example, if the array is $$$a = [7, 1, \textbf{6}, 2, 4, 3, \textbf{5}]$$$, one of the possible operations is to set $$$i = 3$$$ and $$$j = 7$$$ to get the new array $$$[7, 1, \textbf{5}, \textbf{6}, 2, 4, 3]$$$.

Given a permutation $$$b$$$ of the array $$$a$$$, find out if $$$b$$$ is achievable from $$$a$$$ by repeatedly applying the operation on $$$a$$$ any number of times (possibly zero).

Input

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

The first line of each test case contains a single integer $$$n$$$ ($$$1 \le n \le 3 \cdot 10^5$$$) — the length of the array.

The second line of each test case contains $$$n$$$ integers $$$a_1, a_2, \dots, a_n$$$ ($$$1 \le a_i \le n$$$) — elements of the array.

The third line of each test case contains $$$n$$$ integers $$$b_1, b_2, \dots, b_n$$$ ($$$1 \le b_i \le n$$$) — a permutation of the array $$$a$$$.

It is guaranteed that the sum of $$$n$$$ over all test cases doesn't exceed $$$3 \cdot 10^5$$$.

Output

For each test case, output on a single line the word "YES" (without quotes, case insensitive) if it is possible to turn the array $$$a$$$ into $$$b$$$ using the aforementioned operation, or "NO" (without quotes, case insensitive) if it is impossible to do so.

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

The possible solutions for all test cases are given below (the bolded elements are the pair chosen for that operation):

Test Case 1: $$$ [\text{2}, \textbf{4}, \text{3}, \textbf{1}] \rightarrow [\text{2}, \text{1}, \text{4}, \text{3}] $$$

Test Case 2: $$$ [\textbf{3}, \text{2}, \text{1}, \textbf{2}] \rightarrow [\text{2}, \text{3}, \text{2}, \text{1}] $$$

Test Case 3: $$$ [\textbf{3}, \textbf{1}, \text{2}, \text{1}] \rightarrow [\text{1}, \text{3}, \text{2}, \text{1}] $$$

Test Case 4: It can be shown that it is impossible to convert $$$a$$$ to $$$b$$$ by performing the operations.

Test Case 5: $$$ [\text{4}, \textbf{3}, \text{1}, \textbf{2}] \rightarrow [\text{4}, \text{2}, \textbf{3}, \textbf{1}] \rightarrow [\textbf{4}, \text{2}, \text{1}, \textbf{3}] \rightarrow [\text{3}, \text{4}, \text{2}, \text{1}] $$$