#include <bits/stdc++.h>
using namespace std;
int pai[501][501];
int main() {
  int t;
  cin >> t;
  while (t--) {
    for (int i = 0; i < 501; i++) {
      for (int j = 0; j < 501; j++) {
        pai[i][j] = 0;
      }
    }
    int n;
    cin >> n;
    map<int, int> mi;
    vector<int> vv(n);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
      cin >> a[i];
      vv[i] = a[i];
    }
    int l = 0;
    for (int i = 1; i <= n; i++) {
      if (vv[i - 1] != l) {
        l = vv[i - 1];
        mi[l] = i;
      }
    }
    for (int i = 0; i < n / 2; i++) {
      ++pai[min(mi[a[i]], mi[a[n - i - 1]])][max(mi[a[i]], mi[a[n - i - 1]])];
    }
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
      cin >> b[i];
    }
    bool ok = 1;
    for (int i = 0; i < n / 2; i++) {
      --pai[min(mi[b[i]], mi[b[n - i - 1]])][max(mi[b[i]], mi[b[n - i - 1]])];
      if (pai[min(mi[b[i]], mi[b[n - i - 1]])]
             [max(mi[b[i]], mi[b[n - i - 1]])] < 0) {
        ok = 0;
      }
    }
    if (n % 2) {
      if (b[n / 2] != a[n / 2]) {
        ok = 0;
      }
    }
    if (ok) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}
