#include <bits/stdc++.h>
using namespace std;
long long int a[505], b[505];
void solve() {
  long long int n;
  cin >> n;
  for (long long int i = 1; i <= n; i++) cin >> a[i];
  for (long long int i = 1; i <= n; i++) cin >> b[i];
  long long int x = (n + 1) / 2;
  if (n % 2 == 1 && a[x] != b[x]) {
    cout << "No\n";
    return;
  }
  multiset<pair<long long int, long long int> > m;
  if (n % 2) {
    for (long long int i = 1; i < x; i++) m.insert({a[x + i], a[x - i]});
    for (long long int i = 1; i < x; i++) {
      pair<long long int, long long int> p = {b[x + i], b[x - i]};
      if (m.find(p) != m.end()) {
        m.erase(m.find(p));
        continue;
      }
      swap(p.first, p.second);
      if (m.find(p) != m.end()) {
        m.erase(m.find(p));
        continue;
      }
      cout << "No\n";
      return;
    }
  } else {
    for (long long int i = 0; i < x; i++) m.insert({a[x - i], a[x + i + 1]});
    for (long long int i = 0; i < x; i++) {
      pair<long long int, long long int> p = {b[x - i], b[x + i + 1]};
      if (m.find(p) != m.end()) {
        m.erase(m.find(p));
        continue;
      }
      swap(p.first, p.second);
      if (m.find(p) != m.end()) {
        m.erase(m.find(p));
        continue;
      }
      cout << "No\n";
      return;
    }
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long int qc;
  cin >> qc;
  for (long long int i = 1; i <= qc; i++) solve();
}
