#P1365F. Swaps Again
Swaps Again
Description
Ayush, Ashish and Vivek are busy preparing a new problem for the next Codeforces round and need help checking if their test cases are valid.
Each test case consists of an integer and two arrays and , of size . If after some (possibly zero) operations described below, array can be transformed into array , the input is said to be valid. Otherwise, it is invalid.
An operation on array is:
- select an integer
- swap the prefix of length with the suffix of length
For example, if array initially is , after performing an operation with , it is transformed into .
Given the set of test cases, help them determine if each one is valid or invalid.
The first line contains one integer — the number of test cases. The description of each test case is as follows.
The first line of each test case contains a single integer — the size of the arrays.
The second line of each test case contains integers , , ..., — elements of array .
The third line of each test case contains integers , , ..., — elements of array .
For each test case, print "Yes" if the given input is valid. Otherwise print "No".
You may print the answer in any case.
Input
The first line contains one integer — the number of test cases. The description of each test case is as follows.
The first line of each test case contains a single integer — the size of the arrays.
The second line of each test case contains integers , , ..., — elements of array .
The third line of each test case contains integers , , ..., — elements of array .
Output
For each test case, print "Yes" if the given input is valid. Otherwise print "No".
You may print the answer in any case.
Note
For the first test case, we can swap prefix with suffix to get .
For the second test case, is already equal to .
For the third test case, it is impossible since we cannot obtain in .
For the fourth test case, we can first swap prefix with suffix to obtain . Now we can swap prefix with suffix to obtain .
For the fifth test case, it is impossible to convert to .