#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n];
    bool ok = 1;
    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 && a[n / 2] != b[n / 2]) {
      ok = 0;
    }
    multiset<pair<int, int> > pst;
    for (int i = 0; i < n / 2; i++) {
      if (a[i] > a[n - 1 - i]) {
        swap(a[i], a[n - 1 - i]);
      }
      pst.insert({a[i], a[n - i - 1]});
    }
    for (int i = 0; i < n / 2; i++) {
      if (b[i] > b[n - 1 - i]) {
        swap(b[i], b[n - 1 - i]);
      }
      if (!pst.count({b[i], b[n - i - 1]})) {
        ok = 0;
        break;
      }
      pst.erase(pst.find({b[i], b[n - 1 - i]}));
    }
    if (!ok) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
}
