#include <bits/stdc++.h>
using namespace std;
template <class c>
struct rge {
  c b, e;
};
template <class c>
rge<c> range(c i, c j) {
  return rge<c>{i, j};
}
template <class c>
auto dud(c* x) -> decltype(cerr << *x, 0);
template <class c>
char dud(...);
struct debug {
  template <class c>
  debug& operator<<(const c&) {
    return *this;
  }
};
mt19937 myrand(time(0));
int main() {
  ios::sync_with_stdio(0);
  cin.tie(), cout.tie();
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    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];
    long long limit = n / 2;
    if (n % 2 == 0) limit--;
    if (n & 1 && a[limit] != b[limit]) {
      cout << "No" << endl;
      continue;
    }
    multiset<pair<long long, long long> > aa, bb;
    for (int i = 0; i <= limit; i++) {
      aa.insert({min(a[i], a[n - i - 1]), max(a[i], a[n - i - 1])});
      bb.insert({min(b[i], b[n - i - 1]), max(b[i], b[n - i - 1])});
    }
    debug() << " ["
            << "aa"
               ": "
            << (aa)
            << "] "
               " ["
            << "bb"
               ": "
            << (bb) << "] ";
    if (aa == bb)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }
  return 0;
}
