#include <bits/stdc++.h>
using namespace std;
const int maxn = 500;
int n, m;
int a[maxn], b[maxn];
pair<int, int> pa[maxn], pb[maxn];
void answer() {
  cin >> n;
  m = n / 2;
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if ((n & 1) && a[m] != b[m]) {
    cout << "No" << '\n';
    return;
  }
  for (int i = 0; i < m; i++) {
    pa[i] = {a[i], a[n - i - 1]};
    if (pa[i].first > pa[i].second) swap(pa[i].first, pa[i].second);
    pb[i] = {b[i], b[n - i - 1]};
    if (pb[i].first > pb[i].second) swap(pb[i].first, pb[i].second);
  }
  sort(pa, pa + m);
  sort(pb, pb + m);
  for (int i = 0; i < m; i++) {
    if (pa[i] != pb[i]) {
      cout << "No" << '\n';
      return;
    }
  }
  cout << "Yes" << '\n';
}
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) answer();
  return 0;
}
