You are given two integer sequences $A$ and $B$ of lengths $2n$ and $2m$, respectively. All elements are non-zero integers.
The sequence $A = (a_1, a_2, \dots, a_{2n})$ satisfies the following condition: for every integer $i$ such that $1 \le i \le n$, there are exactly two indices $j$ such that $|a_j| = i$. In particular, $\{|a_j| : 1 \le j \le 2n\} = \{1, 2, \dots, n\}$, and each absolute value appears exactly twice (if we disregard the signs).
The sequence $B = (b_1, b_2, \dots, b_{2m})$ satisfies a similar condition: for every $i$ such that $1 \le i \le m$, there are exactly two indices $j$ such that $|b_j| = i$.
You may perform the following operations on the sequence $A$, in any order and any number of times:
- Cyclic shift. Regard the current sequence as a cycle, and perform a rotation: $$(a_1, a_2, \dots, a_{2k}) \longrightarrow (a_{r+1}, a_{r+2}, \dots, a_{2k}, a_1, \dots, a_r)$$ where $0 \le r < 2k$.
- Delete a prefix of a pair of opposite numbers. If the current sequence has the form $A = (x, -x, S_1)$, where $x \neq 0$ and $S_1$ may be empty, you may replace $A$ by $S_1$; that is, delete the first two elements, $x$ and $-x$.
- Insert a new pair of opposite numbers at the front. If the current sequence is $A = (S_1)$ (may be empty), you may replace it by $(x, -x, S_1)$, where $x \neq 0$, and neither $x$ nor $-x$ appears anywhere in $S_1$.
- Reverse and negate. If the current sequence is $$A = (a_1, a_2, \dots, a_{2k})$$ you may replace it by $$\text{nRev}(A) = (-a_{2k}, -a_{2k-1}, \dots, -a_1)$$
Rearrange across a cut. Choose a cut that splits the current sequence into a prefix and a suffix. Suppose the sequence can be written as $$A = (S_1, x, S_2, S_3, y, S_4)$$ where $x > 0$, $y \in \{x, -x\}$, and the cut is between $S_2$ and $S_3$. Here, $S_1$, $S_2$, $S_3$, and $S_4$ may be empty sequences. Then you may apply one of the following transformations:
- If $y = x$ (that is, you choose a pair $x$ and $x$), you may replace $A$ by $$(S_1, \text{nRev}(S_3), x, \text{nRev}(S_4), S_2, y)$$
- If $y = -x$ (that is, you choose a pair $x$ and $-x$), you may replace $A$ by $$(S_1, S_4, x, S_3, S_2, y)$$
You have to determine if it is possible to transform sequence $A$ into a sequence that is equivalent to sequence $B$ by applying these operations a finite number of times.
Let $C = (c_1, \dots, c_{2k})$ and $D = (d_1, \dots, d_{2k})$ be two integer sequences of the same length. We say that $C$ and $D$ are equivalent if and only if there exists a mapping $f : \mathbb{Z} \to \mathbb{Z}$ such that:
- for every integer $x$, $f(-x) = -f(x)$,
- whenever $f(x) \neq 0$, the integers $x$ and $f(x)$ have the same sign (both positive or both negative),
and for all $1 \le i \le 2k$ we have $d_i = f(c_i)$. In other words, if we replace each element $c_i$ of the sequence $C$ by $f(c_i)$, we obtain the sequence $D$. The values of $f$ on integers that do not occur in the sequences may be chosen arbitrarily.
Input
The first line contains a single integer $t$ ($1 \le t \le 10^5$), the number of test cases. For each test case:
The first line contains an integer $n$ ($1 \le n \le 5 \cdot 10^5$), denoting that the length of sequence $A$ is $2n$.
The second line contains $2n$ integers, denoting $a_1, a_2, \dots, a_{2n}$.
The third line contains an integer $m$ ($1 \le m \le 5 \cdot 10^5$), denoting that the length of sequence $B$ is $2m$.
The fourth line contains $2m$ integers, denoting $b_1, b_2, \dots, b_{2m}$.
The sequences $A$ and $B$ meet the requirements in the statement.
The total size of all test cases is bounded by $\sum n + \sum m \le 10^6$.
Output
For each test case, if it is possible to make $A$ equivalent to $B$, output YES; otherwise, output NO.
Examples
4
1
1 -1
2
-1 -2 2 1
1
1 1
1
-1 1
4
1 2 -1 3 -4 2 3 -4
4
1 2 -1 -2 4 3 4 3
4
4 3 -1 -2 -3 2 1 -4
3
-1 1 3 -3 2 2
YES
NO
YES
NO
5
4
1 2 -3 -2 4 -1 3 -4
6
-3 5 2 3 -2 -5 1 -6 -4 -1 4 6
5
-2 4 -4 3 2 -1 -5 1 -3 5
5
3 -4 1 -5 4 -1 2 -2 -3 5
4
-2 1 4 2 -4 3 -1 -3
5
-1 -5 -2 2 1 -4 -3 3 4 5
3
2 -1 -1 -3 -2 3
4
-4 -2 -1 4 1 -2 3 -3
5
3 5 -5 -2 2 -1 -3 -4 1 4
5
3 5 -2 -5 -1 2 -4 1 4 -3
YES
YES
NO
YES
NO
Note
In the first example:
In the first test case, $(1, -1) \xrightarrow{\text{op 3}} (-2, 2, 1, -1) \xrightarrow{\text{op 1}} (-1, -2, 2, 1)$.
In the third test case, suppose $x = 3$, $y = 3$, $S_1 = (1, 2, -1)$, $S_3 = (-4, 2)$, $S_4 = (-4)$, and $S_2$ is empty. Then $A = (S_1, x, S_2, S_3, y, S_4)$, and $A \xrightarrow{\text{op 5}} (1, 2, -1, -2, 4, 3, 4, 3)$.