#include <bits/stdc++.h>
using namespace std;
void swap(long long int &a, long long int &b) {
  auto tm = a;
  a = b;
  b = tm;
}
long long int power(long long int x, long long int y) {
  long long int sum = 1;
  for (long long int i = 0; i < y; i++) sum *= x;
  return sum;
}
long long int fact(long long int n) {
  long long int res = 1;
  for (long long int i = 2; i <= n; i++) res = res * i;
  return res;
}
long long int nCr(long long int n, long long int r) {
  return fact(n) / (fact(r) * fact(n - r));
}
const int N = 100005;
void solve() {
  long long int i, j, k, q, x, y;
  long long int cnt = 0, n;
  map<pair<long long int, long long int>, long long int> m;
  cin >> n;
  long long int a[n], b[n];
  for (i = 0; i < n; i++) cin >> a[i];
  for (i = 0; i < n; i++) cin >> b[i];
  for (i = 0; i < n / 2; i++) {
    m[{a[i], a[n - 1 - i]}]++;
    m[{a[n - 1 - i], a[i]}]++;
  }
  if (n % 2) {
    if (a[n / 2] != b[n / 2]) {
      cout << "No";
      return;
    }
  }
  for (i = 0; i < n / 2; i++) {
    if (m[{b[i], b[n - 1 - i]}] <= 0) {
      cout << "No";
      return;
    } else {
      m[{b[i], b[n - 1 - i]}]--;
      m[{b[n - 1 - i], b[i]}]--;
    }
  }
  cout << "Yes";
}
signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int tt = 1.0 * clock();
  int t;
  cin >> t;
  for (int y = 0; y < t; y++) {
    solve();
    cout << endl;
  }
}
