#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t, n, k, i, j;
  cin >> t;
  while (t--) {
    cin >> n;
    int a[n];
    int b[n];
    vector<pair<int, int> > v1, v2;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) cin >> b[i];
    if (n % 2 && a[n / 2] != b[n / 2]) {
      cout << "No\n";
      continue;
    }
    for (i = 0; i < n - 1 - i; i++) {
      if (a[i] > a[n - 1 - i]) swap(a[i], a[n - 1 - i]);
      v1.push_back({a[i], a[n - 1 - i]});
    }
    for (i = 0; i < n - 1 - i; i++) {
      if (b[i] > b[n - 1 - i]) swap(b[i], b[n - 1 - i]);
      v2.push_back({b[i], b[n - 1 - i]});
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    for (i = 0; i < v1.size(); i++)
      if (v1[i] != v2[i]) {
        break;
      }
    if (i < v1.size())
      cout << "No\n";
    else
      cout << "Yes\n";
  }
  return 0;
}
