#include <bits/stdc++.h>
using namespace std;
const double pi = acos(-1);
const int N = 1e5 + 5;
int a[N];
int b[N];
int main() {
  ios_base::sync_with_stdio(false);
  int T;
  cin >> T;
  while (T--) {
    int n;
    cin >> n;
    vector<int> ve1, ve2;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) ve1.push_back(a[i]);
    for (int i = 0; i < n; i++) ve2.push_back(b[i]);
    sort(ve1.begin(), ve1.end());
    sort(ve2.begin(), ve2.end());
    multiset<pair<int, long long> > mse;
    bool res = true;
    for (int i = 0; i < (n + 1) / 2; i++) {
      int mn = min(a[i], a[n - i - 1]);
      int mx = max(a[i], a[n - i - 1]);
      mse.insert({mn, mx});
    }
    for (int i = 0; i < (n + 1) / 2; i++) {
      int mn = min(b[i], b[n - i - 1]);
      int mx = max(b[i], b[n - i - 1]);
      pair<int, long long> x = {mn, mx};
      if (mse.find(x) != mse.end()) {
        mse.erase(mse.find(x));
      } else {
        res = false;
      }
    }
    if (res)
      cout << "YES\n";
    else
      cout << "NO\n";
  }
  return 0;
}
