#include <bits/stdc++.h>
using namespace std;
mt19937_64 mt_rnd_64(chrono::steady_clock::now().time_since_epoch().count());
long long rnd(long long l, long long r) {
  return (mt_rnd_64() % (r - l + 1)) + l;
}
using ll = long long;
using ld = long double;
using ull = unsigned long long;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
const ll INF = 1e15;
const int inf = 1e6;
const int N = 2 * 1e6 + 10;
vector<pair<int, int> > mv = {{0, 1}, {0, -1}, {-1, 0}, {1, 0}};
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << setprecision(10) << fixed;
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    bool first = 0;
    for (int &i : a) cin >> i;
    for (int &i : b) cin >> i;
    if (n % 2 && a[n / 2] != b[n / 2]) {
      cout << "NO\n";
      continue;
    }
    vector<pair<int, int> > A, B;
    for (int i = 0; i < n / 2; ++i) {
      A.push_back({max(a[i], a[n - 1 - i]), min(a[i], a[n - 1 - i])});
      B.push_back({max(b[i], b[n - 1 - i]), min(b[i], b[n - 1 - i])});
    }
    sort(begin(A), end(A));
    sort(begin(B), end(B));
    if (A == B) {
      cout << "YES\n";
    } else {
      cout << "NO\n";
    }
  }
  return 0;
}
