#include <bits/stdc++.h>
using namespace std;
template <typename X>
ostream& operator<<(ostream& x, const vector<X>& v) {
  for (long long i = 0; i < v.size(); ++i) x << v[i] << " ";
  return x;
}
template <typename X>
ostream& operator<<(ostream& x, const set<X>& v) {
  for (auto it : v) x << it << " ";
  return x;
}
template <typename X, typename Y>
ostream& operator<<(ostream& x, const pair<X, Y>& v) {
  x << v.first << " " << v.second;
  return x;
}
template <typename T, typename S>
ostream& operator<<(ostream& os, const map<T, S>& v) {
  for (auto it : v) os << it.first << "=>" << it.second << endl;
  return os;
}
long long n;
long long const N = 501;
long long a[N];
long long b[N];
void solve() {
  cin >> n;
  for (long long i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (long long i = 0; i < n; i++) {
    cin >> b[i];
  }
  if (n & 1) {
    if (a[n / 2] != b[n / 2]) {
      cout << "No\n";
      return;
    }
  }
  vector<pair<long long, long long> > c, d;
  for (long long i = 0; i < n / 2; i++) {
    if (a[i] > a[n - i - 1]) {
      swap(a[i], a[n - i - 1]);
    }
    if (b[i] > b[n - i - 1]) {
      swap(b[i], b[n - i - 1]);
    }
    c.push_back({a[i], a[n - i - 1]});
    d.push_back({b[i], b[n - i - 1]});
  }
  sort(c.begin(), c.end());
  sort(d.begin(), d.end());
  42;
  42;
  if (c != d) {
    cout << "No\n";
  } else {
    cout << "Yes\n";
  }
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
