#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int a[N];
int b[N];
vector<pair<int, int>> seta, setb;
void solve() {
  seta.clear();
  setb.clear();
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) cin >> a[i];
  for (int i = 1; i <= n; i++) cin >> b[i];
  if (n % 2) {
    if (a[n / 2 + 1] != b[n / 2 + 1]) {
      cout << "No\n";
      return;
    }
  }
  for (int i = 1, j = n; i < j; i++, j--) {
    int x = a[i], y = a[j];
    if (x > y) swap(x, y);
    seta.push_back({x, y});
    x = b[i], y = b[j];
    if (x > y) swap(x, y);
    setb.push_back({x, y});
  }
  sort(seta.begin(), seta.end());
  sort(setb.begin(), setb.end());
  for (int i = 0; i < seta.size(); i++) {
    if (seta[i] != setb[i]) {
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0), cout.tie(0);
  int nrt;
  cin >> nrt;
  for (int i = 1; i <= nrt; i++) {
    solve();
  }
  return 0;
}
