#include <bits/stdc++.h>
using pii = std::pair<long long, long long>;
using namespace std;
const long long maxn = 505;
long long t, n, a[maxn], b[maxn];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  for (long long cases = 0; cases < t; cases++) {
    cin >> n;
    map<long long, long long> cnt;
    for (long long i = 0; i < n; i++) {
      cin >> a[i];
      cnt[a[i]]++;
    }
    for (long long i = 0; i < n; i++) {
      cin >> b[i];
      cnt[b[i]]--;
    }
    long long good = 1;
    for (auto x : cnt)
      if (x.second != 0) good = 0;
    if ((n & 1) && (a[n / 2] != b[n / 2])) good = 0;
    multiset<pii> pairs;
    for (long long i = 0; i < n / 2; i++)
      pairs.insert({min(a[i], a[n - 1 - i]), max(a[i], a[n - 1 - i])});
    for (long long i = 0; i < n / 2; i++) {
      long long fi = min(b[i], b[n - 1 - i]);
      long long se = max(b[i], b[n - 1 - i]);
      if (!pairs.count({fi, se})) {
        good = 0;
        break;
      }
      pairs.erase(pairs.find({fi, se}));
    }
    if (good)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
