#include <bits/stdc++.h>
using namespace std;
const int N = 1e3 + 7;
long long a[N], b[N];
void solve() {
  int n;
  cin >> n;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  multiset<pair<int, int> > msa;
  multiset<pair<int, int> > msb;
  msa.clear();
  msb.clear();
  if (n % 2 == 1)
    if (a[n / 2] != b[n / 2]) {
      cout << "No" << endl;
      return;
    }
  for (int i = 0; i < n / 2; i++) {
    int ae1 = a[i];
    int ae2 = a[n - i - 1];
    if (ae1 < ae2)
      msa.insert({ae1, ae2});
    else
      msa.insert({ae2, ae1});
  }
  for (int i = 0; i < n / 2; i++) {
    int be1 = b[i];
    int be2 = b[n - i - 1];
    if (be1 < be2)
      msb.insert({be1, be2});
    else
      msb.insert({be2, be1});
  }
  if (msa == msb)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
