#include <bits/stdc++.h>
using namespace std;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  for (auto &x : a) cin >> x;
  for (auto &y : b) cin >> y;
  bool flag = true;
  map<pair<int, int>, int> mp;
  if (n % 2 == 1 && (a[n / 2] != b[n / 2])) {
    flag = false;
  }
  for (int i = 0; i < n / 2; i++) {
    pair<int, int> p;
    if (a[i] < a[n - i - 1])
      p = make_pair(a[i], a[n - i - 1]);
    else
      p = make_pair(a[n - i - 1], a[i]);
    mp[p]++;
  }
  for (int i = 0; i < n / 2; i++) {
    pair<int, int> p;
    if (b[i] < b[n - i - 1])
      p = make_pair(b[i], b[n - i - 1]);
    else
      p = make_pair(b[n - i - 1], b[i]);
    if (mp[p] <= 0) flag = false;
    mp[p]--;
  }
  if (flag)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int test;
  cin >> test;
  while (test--) solve();
}
