#include <bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimization("O3")
#pragma GCC optimization("unroll-loops")
using namespace std;
vector<long long int> v, v1, v2, v3, v4;
vector<pair<long long int, pair<long long int, long long int> > > vec1;
vector<pair<int, int> > vec;
vector<int> adj[500005];
map<long long int, long long int> Mp, Mp1, Mp2;
set<int> st, st1, st2;
queue<long long int> Q;
stack<long long int> Stk;
multiset<pair<long long int, long long int> > A, B;
long long int n;
void pre() {}
void Reset() {
  v1.clear();
  v2.clear();
  A.clear();
  B.clear();
}
void Input() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    v1.push_back(temp);
  }
  for (int i = 0; i < n; i++) {
    long long int temp;
    cin >> temp;
    v2.push_back(temp);
  }
}
void Calculation() {
  for (int i = 0; i < n; i++) {
    A.insert({v1[i], v1[n - i - 1]});
    B.insert({v2[i], v2[n - i - 1]});
  }
  if (A == B) {
    cout << "YES" << endl;
    ;
  } else {
    cout << "NO" << endl;
    ;
  }
}
void solve() {
  Reset();
  Input();
  Calculation();
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
