#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = 0; i < n; ++i) cin >> b[i];
    bool ok = true;
    if (n % 2 == 1 && a[n / 2] != b[n / 2]) ok = false;
    map<pair<int, int>, int> cnt;
    for (int i = 0; i < n / 2; ++i) {
      ++cnt[{min(a[i], a[n - i - 1]), max(a[i], a[n - i - 1])}];
    }
    for (int i = 0; i < n / 2; ++i) {
      if (cnt[{min(b[i], b[n - i - 1]), max(b[i], b[n - i - 1])}] == 0) {
        ok = false;
      }
      --cnt[{min(b[i], b[n - i - 1]), max(b[i], b[n - i - 1])}];
    }
    cout << (ok ? "Yes" : "No") << '\n';
  }
}
