#include <bits/stdc++.h>
using namespace std;
int n;
vector<int> a, b;
bool answer;
void In() {
  a.clear();
  b.clear();
  cin >> n;
  a.resize(n);
  for (int i = 0; i < n; i++) cin >> a[i];
  b.resize(n);
  for (int i = 0; i < n; i++) cin >> b[i];
}
bool Solve() {
  vector<pair<int, int>> half_a, half_b;
  for (int i = 0, j = n - 1; i <= j; i++, j--) half_a.push_back({a[i], a[j]});
  for (int i = 0, j = n - 1; i <= j; i++, j--) half_b.push_back({b[i], b[j]});
  for (auto& value : half_a)
    if (value.first > value.second) swap(value.first, value.second);
  for (auto& value : half_b)
    if (value.first > value.second) swap(value.first, value.second);
  sort(half_a.begin(), half_a.end());
  sort(half_b.begin(), half_b.end());
  for (int i = 0; i < half_a.size(); i++)
    if (half_a[i] != half_b[i]) return false;
  return true;
}
void Out() { cout << (answer ? "Yes" : "No") << '\n'; }
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t = 1;
  cin >> t;
  while (t--) {
    In();
    answer = Solve();
    Out();
  }
}
