#include <bits/stdc++.h>
using namespace std;
const int N = 505, M = 1;
int T, n, a[N], b[N];
void solve() {
  vector<pair<int, int> > va, vb;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int j = 1; j <= n; j++) cin >> b[j];
  if (n % 2 && a[n / 2 + 1] != b[n / 2 + 1]) {
    puts("No");
    return;
  }
  for (int i = 1; i <= n / 2; i++) {
    if (a[i] > a[n - i + 1]) swap(a[i], a[n - i + 1]);
    if (b[i] > b[n - i + 1]) swap(b[i], b[n - i + 1]);
    va.push_back({a[i], a[n - i + 1]});
    vb.push_back({b[i], b[n - i + 1]});
  }
  sort(va.begin(), va.end());
  sort(vb.begin(), vb.end());
  for (int i = 0; i < n / 2; i++) {
    if (va[i] != vb[i]) {
      puts("No");
      return;
    }
  }
  puts("Yes");
}
int main() {
  ios::sync_with_stdio(false);
  cin >> T;
  while (T--) {
    solve();
  }
  return 0;
}
