#include <bits/stdc++.h>
using namespace std;
const long long int MAX = 1e5 + 5;
const long long int INF = 2e18;
void ans(int a) {
  if (a)
    cout << "Yes\n";
  else
    cout << "No\n";
}
void solve() {
  int n;
  cin >> n;
  int a[n], b[n];
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < n; i++) cin >> b[i];
  if (n & 1) {
    if (a[n / 2] != b[n / 2]) {
      ans(0);
      return;
    }
  }
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n / 2; i++) {
    if (a[i] > a[n - i - 1]) swap(a[i], a[n - i - 1]);
    mp[{a[i], a[n - i - 1]}]++;
  }
  int first = 1;
  for (int i = 0; i < n / 2; i++) {
    if (b[i] > b[n - i - 1]) swap(b[i], b[n - i - 1]);
    if (mp[{b[i], b[n - i - 1]}] <= 0) first = 0;
    mp[{b[i], b[n - i - 1]}]--;
  }
  ans(first);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  cin >> t;
  while (t--) solve();
  return 0;
}
