#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[n], b[n];
  map<pair<int, int>, int> mpa, mpb;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0, j = n - 1; i < j; i++, j--) {
    int x = a[i];
    int y = a[j];
    if (x > y) swap(x, y);
    mpa[{x, y}]++;
  }
  for (int i = 0, j = n - 1; i < j; i++, j--) {
    int x = b[i];
    int y = b[j];
    if (x > y) swap(x, y);
    mpb[{x, y}]++;
  }
  bool ok = true;
  for (auto it : mpa) {
    if (it.second != mpb[{it.first.first, it.first.second}]) {
      ok = false;
      break;
    }
  }
  if (n % 2) {
    if (a[n / 2] != b[n / 2]) ok = false;
  }
  cout << (ok ? "YES\n" : "NO\n");
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(NULL);
  int t = 1;
  cin >> t;
  for (int i = 1; i <= t; i++) {
    solve();
  }
  return 0;
}
