#include <bits/stdc++.h>
using namespace std;
vector<int> adj[55];
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    long long int arr1[n], arr2[n];
    for (int i = 0; i < n; i++) cin >> arr1[i];
    for (int i = 0; i < n; i++) cin >> arr2[i];
    int k = (n + 1) / 2;
    if (n % 2) {
      if (arr1[k - 1] != arr2[k - 1]) {
        cout << "No" << endl;
        continue;
      }
    }
    bool flag = true;
    vector<pair<long long int, long long int> > v1, v2;
    for (int i = 0; i < k; i++) {
      long long int num1 = arr1[i], num2 = arr1[n - i - 1];
      v1.push_back(make_pair(min(num1, num2), max(num1, num2)));
      num1 = arr2[i], num2 = arr2[n - i - 1];
      v2.push_back(make_pair(min(num1, num2), max(num1, num2)));
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    for (int i = 0; i < k; i++) {
      pair<long long int, long long int> P1 = v1[i], P2 = v2[i];
      if (P1 != P2) flag = false;
    }
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
