NOI Contest Archive

Archive / 2020 / June 2020

Make It Same

Medium · National Olympiad in Informatics Sri Lanka - June 2020

You are given two arrays a and b with m elements. If you can convert b (array) to a (array) after doing the operations described below, output “Yes” otherwise output “No” (Without quotes).

  1. select an integer k (1 \(\leq\) k \(\leq\) m/2).
  2. swap the prefix of length k with the suffix of length k.
  3. You can do these operations any number of times(Possibly zero).

For an example if b={1,2,3,4,5,6}

Input Format

The first line contains one integer n — the number of test cases.

The first line of each test case contains a single integer m — nuumber of elements in the arrays.

The second line of each test case contains m integers a1, a2, …, am (1 \(\leq\) ai \(\leq\) 10000) — elements of array a.

The third line of each test case contains m integers b1, b2, …, bm (1 \(\leq\) bi \(\leq\) 10000) — elements of array b.

Output Format

For each test case, print “Yes” (Without quotes) if you can convert b (array) to a (array). Otherwise print “No” (Without quotes).

Constraints

Limits

Sample Input 0

5
2
1 2
2 1
3
1 2 3
1 2 3
3
1 2 4
1 3 4
4
1 2 3 2
3 1 2 2
3
1 2 3
1 3 2

Sample Output 0

Yes
Yes
No
Yes
No