#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 42;
bool check(pair<int, int> a, pair<int, int> b) {
  if (a.first > a.second) {
    swap(a.first, a.second);
  }
  if (b.first > b.second) {
    swap(b.first, b.second);
  }
  return a == b;
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int A[n];
    for (int i = 0; i < n; ++i) {
      cin >> A[i];
    }
    int B[n];
    for (int i = 0; i < n; ++i) {
      cin >> B[i];
    }
    if (n % 2 == 1 && A[n >> 1] != B[n >> 1]) {
      cout << "No\n";
      continue;
    }
    pair<int, int> A_[n >> 1], B_[n >> 1];
    for (int i = 0; i < (n >> 1); ++i) {
      A_[i] = make_pair(A[i], A[n - i - 1]);
      if (A_[i].first > A_[i].second) {
        swap(A_[i].first, A_[i].second);
      }
      B_[i] = make_pair(B[i], B[n - i - 1]);
      if (B_[i].first > B_[i].second) {
        swap(B_[i].first, B_[i].second);
      }
    }
    sort(A_, A_ + (n >> 1));
    sort(B_, B_ + (n >> 1));
    bool OK = true;
    for (int i = 0; i < (n >> 1); ++i) {
      if (A_[i] != B_[i]) {
        OK = false;
        break;
      }
    }
    if (!OK) {
      cout << "No\n";
    } else {
      cout << "Yes\n";
    }
  }
  cerr << 1.0 * clock() / CLOCKS_PER_SEC << "\n";
  return 0;
}
