#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  int a[512], b[512];
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  if (n % 2 == 1) {
    int m = n / 2;
    if (a[m] != b[m]) {
      cout << "No" << endl;
      return;
    }
  }
  map<vector<int>, int> m;
  for (int i = 0; i < n / 2; ++i) {
    int j = n - i - 1;
    if (a[i] > a[j]) {
      swap(a[i], a[j]);
    }
    if (b[i] > b[j]) {
      swap(b[i], b[j]);
    }
  }
  bool used[512] = {};
  for (int i = 0; i < n / 2; ++i) {
    int invI = n - i - 1;
    bool found = false;
    for (int j = 0; j < n / 2; ++j) {
      int invJ = n - j - 1;
      if (!used[j] && (a[i] == b[j] && a[invI] == b[invJ])) {
        used[j] = true;
        found = true;
        break;
      }
    }
    if (!found) {
      cout << "No" << endl;
      return;
    }
  }
  cout << "Yes" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int T;
  cin >> T;
  for (int t = 0; t < T; ++t) {
    solve();
  }
  return 0;
}
