#include <bits/stdc++.h>
using namespace std;
mt19937 gen(time(0));
bool IS_ONE_TEST = 0;
void solve() {
  long long n;
  cin >> n;
  vector<long long> a(n), b(n);
  vector<pair<int, int>> pa, pb;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  for (int i = 0; i <= (n - 1) / 2; ++i) {
    pa.emplace_back(min(a[i], a[n - i - 1]), max(a[i], a[n - i - 1]));
    pb.emplace_back(min(b[i], b[n - i - 1]), max(b[i], b[n - i - 1]));
  }
  sort(pa.begin(), pa.end());
  sort(pb.begin(), pb.end());
  if ((n & 1) && a[n / 2] != b[n / 2]) {
    cout << "No" << endl;
    return;
  }
  cout << (pa == pb ? "Yes" : "No") << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << fixed << setprecision(15);
  int t;
  if (IS_ONE_TEST)
    t = 1;
  else
    cin >> t;
  while (t-- > 0) {
    solve();
  }
}
