#include <bits/stdc++.h>
long long INF = (1ll << 61);
using namespace std;
void print(vector<long long>& v) {
  for (auto k : v) cout << k << " ";
  cout << " : ";
}
int main(int argc, char* argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int test_casesq;
  cin >> test_casesq;
  for (int xt = 0; xt < test_casesq; xt++) {
    int n;
    cin >> n;
    vector<long long> a(n), b(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    bool fl = 1;
    if (n % 2) fl = (a[n / 2] == b[n / 2]);
    multiset<pair<long long, long long> > s;
    multiset<pair<long long, long long> > t;
    for (int i = 0; i < n / 2; i++) {
      s.insert({a[i], a[n - i - 1]});
      s.insert({a[n - i - 1], a[i]});
      t.insert({b[i], b[n - i - 1]});
      t.insert({b[n - i - 1], b[i]});
    }
    fl = fl && (s == t);
    if (fl) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}
