#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const long long INF = 1e18;
int main() {
  cin.tie(0);
  cout.tie(0);
  ios_base::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n, i;
    cin >> n;
    vector<int> A(n), B(n);
    vector<pair<int, int> > C(n / 2), D(n / 2);
    for (i = 0; i < n; i++) cin >> A[i];
    for (i = 0; i < n; i++) cin >> B[i];
    vector<int> A1 = A, B1 = B;
    sort(A1.begin(), A1.end());
    sort(B1.begin(), B1.end());
    if (A1 != B1 || ((n & 1) && A[n / 2] != B[n / 2])) {
      cout << "No" << endl;
      continue;
    }
    for (i = 0; i < n / 2; i++) {
      C[i].first = A[i];
      C[i].second = A[n - i - 1];
      if (C[i].second < C[i].first) swap(C[i].first, C[i].second);
      D[i].first = B[i];
      D[i].second = B[n - i - 1];
      if (D[i].second < D[i].first) swap(D[i].first, D[i].second);
    }
    sort(C.begin(), C.end());
    sort(D.begin(), D.end());
    bool first = true;
    for (i = 0; i < n / 2; i++)
      if (C[i] != D[i]) {
        cout << "No" << endl;
        first = false;
        break;
      }
    if (first) cout << "Yes" << endl;
  }
}
