#include <bits/stdc++.h>
using namespace std;
void func(void) {
  freopen("input.c", "r", stdin);
  freopen("output.c", "w", stdout);
}
void print(vector<long long> &v) {
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    printf("%lld ", v[i]);
  }
  printf("\n");
}
void print(vector<pair<long long, long long> > &v) {
  cout << v.size() << endl;
  for (int i = 0; i < v.size(); i++) {
    printf("%lld %lld\n", v[i].first, v[i].second);
  }
}
void print(double d) { cout << fixed << setprecision(10) << d << endl; }
void print(string s, double d) {
  cout << s << " ";
  cout << fixed << setprecision(10) << d << endl;
}
int main() {
  long long n, q, i, j = 0, temp, t, k, ans = 0, sum = 0, x, y, z, cnt = 0, m,
                     fg = 0, mx = 0, mx1 = 0, mn = 8000000000000000000,
                     mn1 = 8000000000000000000;
  cin >> t;
  while (t--) {
    cin >> n;
    vector<int> v1, v2, temp1;
    for (int i = 0; i < n; i++) {
      cin >> x;
      v1.push_back(x);
    }
    for (int i = 0; i < n; i++) {
      cin >> x;
      v2.push_back(x);
    }
    int mid = (n + 1) / 2;
    vector<pair<int, int> > vp1, vp2;
    for (int i = 0; i < mid; i++) {
      vp1.push_back({v1[i], v1[n - i - 1]});
      vp2.push_back({v2[i], v2[n - i - 1]});
      if (vp1[i].first > vp1[i].second) swap(vp1[i].first, vp1[i].second);
      if (vp2[i].first > vp2[i].second) swap(vp2[i].first, vp2[i].second);
    }
    sort(vp1.begin(), vp1.end());
    sort(vp2.begin(), vp2.end());
    if (vp1 == vp2) {
      cout << "Yes\n";
    } else
      cout << "No\n";
  }
}
