#include <bits/stdc++.h>
using namespace std;
int a[505], b[505], n, t;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    bool ok = 1;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    if (n & 1) {
      if (a[n / 2] != b[n / 2]) {
        cout << "NO" << endl;
        continue;
      }
    }
    multiset<pair<int, int>> x, y;
    for (int i = 0; i < n / 2; i++) {
      if (a[i] > a[n - 1 - i]) swap(a[i], a[n - 1 - i]);
      if (b[i] > b[n - 1 - i]) swap(b[i], b[n - 1 - i]);
      x.insert({a[i], a[n - 1 - i]});
      y.insert({b[i], b[n - 1 - i]});
    }
    for (auto v : x) {
      if (x.count(v) != y.count(v)) {
        ok = 0;
        break;
      }
    }
    if (ok)
      cout << "YES" << endl;
    else
      cout << "NO" << endl;
  }
  return 0;
}
