#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y > 0) {
    if (y & 1) res = res * x;
    y = y >> 1;
    x = x * x;
  }
  return res;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    std::vector<long long> aa, bb;
    multiset<long long> a, b;
    long long flag = 0;
    map<pair<long long, long long>, long long> map;
    for (long long i = 0; i < n; ++i) {
      long long x;
      cin >> x;
      a.insert(x);
      aa.push_back(x);
    }
    for (long long i = 0; i < n; ++i) {
      long long x;
      cin >> x;
      b.insert(x);
      bb.push_back(x);
    }
    if (a != b)
      flag = 1;
    else if (n & 1 && aa[n / 2] != bb[n / 2])
      flag = 1;
    if (!flag) {
      for (long long i = 0; i < n / 2; ++i) {
        map[make_pair(min(aa[i], aa[n - i - 1]), max(aa[i], aa[n - i - 1]))]++;
      }
      for (long long i = 0; i < n / 2; ++i) {
        if (map[make_pair(min(bb[i], bb[n - i - 1]),
                          max(bb[i], bb[n - i - 1]))] <= 0) {
          flag = 1;
          break;
        } else
          map[make_pair(min(bb[i], bb[n - i - 1]),
                        max(bb[i], bb[n - i - 1]))]--;
      }
    }
    if (flag)
      cout << "NO"
           << "\n";
    else
      cout << "YES"
           << "\n";
  }
  return 0;
}
