#include <bits/stdc++.h>
using namespace std;
const int inf = 1e09 + 5e3;
const long long linf = 2e18 + 5e3;
const int mxn = 5e2 + 5;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  vector<pair<int, int> > as, bs;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  long long out = 1;
  if (n & 1) out = a[n / 2] == b[n / 2];
  for (int i = 0, j = n - 1; i < n / 2; i++, j--) {
    as.emplace_back(min(a[i], a[j]), max(a[i], a[j]));
    bs.emplace_back(min(b[i], b[j]), max(b[i], b[j]));
  }
  sort((as).begin(), (as).end());
  sort((bs).begin(), (bs).end());
  cout << (out && as == bs ? "Yes" : "No") << '\n';
}
int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
}
