#include <bits/stdc++.h>
using namespace std;
const int MAX_N = 2e5 + 5;
const int M = 1e6;
const long long INF = (long long)(1e18);
const int inf = 1e9;
const long long MOD = 1000000007LL;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  if (n % 2) {
    int mid = n / 2;
    if (a[mid] != b[mid]) {
      cout << "No\n";
      return;
    }
  }
  map<pair<int, int>, int> mpA, mpB;
  int j = n - 1;
  for (int i = 0; i < n / 2; i++) {
    int x = min(a[i], a[j]);
    int y = max(a[i], a[j]);
    j--;
    mpA[{x, y}]++;
  }
  j = n - 1;
  for (int i = 0; i < n / 2; i++) {
    int x = min(b[i], b[j]);
    int y = max(b[i], b[j]);
    j--;
    mpB[{x, y}]++;
  }
  for (auto it : mpA) {
    pair<int, int> what = it.first;
    int cnt = it.second;
    if (mpB[what] != cnt) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int T;
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
