#include <bits/stdc++.h>
using namespace std;
const long long max_n = 500 + 5;
long long n;
long long a[max_n], b[max_n];
bool are_equal(long long arr1[], long long arr2[], long long sz) {
  for (int i = 0; i < sz; ++i) {
    if (arr1[i] != arr2[i]) return false;
  }
  return true;
}
bool same_elements(long long arr1[], long long arr2[], long long sz) {
  long long tarr1[sz], tarr2[sz];
  for (int i = 0; i < sz; ++i) {
    tarr1[i] = arr1[i];
    tarr2[i] = arr2[i];
  }
  sort(tarr1, tarr1 + sz);
  sort(tarr2, tarr2 + sz);
  return are_equal(tarr1, tarr2, sz);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    for (int z = 0; z < n; ++z) cin >> a[z];
    ;
    for (int z = 0; z < n; ++z) cin >> b[z];
    ;
    if (!same_elements(a, b, n) or (n & 1 and a[n / 2] != b[n / 2])) {
      cout << "No\n";
      continue;
    }
    vector<pair<long long, long long> > p;
    for (int i = 0; i < (n / 2); ++i) p.push_back({a[i], a[n - 1 - i]});
    bool flag = true;
    for (int i = 0; i < (n / 2) and flag; ++i) {
      long long x;
      bool got = false;
      pair<long long, long long> temp = {b[i], b[n - 1 - i]};
      for (x = 0; x < p.size() and !got; ++x) {
        if (p[x] == temp) {
          p.erase(p.begin() + x);
          got = true;
        }
      }
      temp = {b[n - 1 - i], b[i]};
      for (x = 0; x < p.size() and !got; ++x) {
        if (p[x] == temp) {
          p.erase(p.begin() + x);
          got = true;
        }
      }
      flag = got;
    }
    if (flag)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
