#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  int t, n, i;
  cin >> t;
  while (t--) {
    cin >> n;
    long long int a[n], b[n];
    bool flag = true;
    for (i = 0; i < n; i++) cin >> a[i];
    for (i = 0; i < n; i++) cin >> b[i];
    if ((n & 1) && a[n / 2] != b[n / 2]) flag = false;
    map<pair<int, int>, int> m;
    for (i = 0; i < n / 2; i++) {
      pair<int, int> p = {min(a[i], a[n - i - 1]), max(a[i], a[n - i - 1])};
      m[p]++;
    }
    for (i = 0; i < n / 2; i++) {
      pair<int, int> p = {min(b[i], b[n - i - 1]), max(b[n - i - 1], b[i])};
      if (m[p] <= 0)
        flag = false;
      else
        m[p]--;
    }
    if (flag)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
}
