#include <bits/stdc++.h>
using namespace std;
int 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];
    int b[n];
    vector<int> v1;
    vector<int> v2;
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      v1.push_back(a[i]);
    }
    for (int i = 0; i < n; i++) {
      cin >> b[i];
      v2.push_back(b[i]);
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    if (v1 == v2) {
      map<pair<int, int>, int> has1;
      map<pair<int, int>, int> has2;
      for (int i = 0; i < n / 2; i++) {
        has1[{a[i], a[n - i - 1]}]++;
        has1[{a[n - i - 1], a[i]}]++;
        has2[{b[i], b[n - i - 1]}]++;
        has2[{b[n - i - 1], b[i]}]++;
      }
      if (has1 == has2) {
        cout << "Yes" << '\n';
      } else {
        cout << "No" << '\n';
      }
    } else {
      cout << "No" << '\n';
    }
  }
  return 0;
}
