#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    ;
    int n;
    cin >> n;
    vector<int> arr1(n);
    vector<int> arr2(n);
    for (int i = 0; i < n; i++) cin >> arr1[i];
    for (int i = 0; i < n; i++) cin >> arr2[i];
    if (n % 2 == 1 && arr1[n / 2] != arr2[n / 2]) {
      cout << "No\n";
    } else {
      vector<pair<int, int> > p1;
      vector<pair<int, int> > p2;
      for (int i = 0; i < n; i++) {
        pair<int, int> c1 = make_pair(arr1[i], arr1[n - 1 - i]);
        if (c1.first > c1.second) swap(c1.first, c1.second);
        pair<int, int> c2 = make_pair(arr2[i], arr2[n - 1 - i]);
        if (c2.first > c2.second) swap(c2.first, c2.second);
        p1.push_back(c1);
        p2.push_back(c2);
      }
      sort(p1.begin(), p1.end());
      sort(p2.begin(), p2.end());
      bool good = 1;
      for (int i = 0; i < n; i++)
        if (p1[i] != p2[i]) good = 0;
      cout << (good ? "yes" : "No") << "\n";
    }
  }
}
