#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
long long bp(long long x, long long y) {
  long long ans = 1;
  x %= mod;
  while (y) {
    if (y & 1) ans = ans * x % mod;
    x = x * x % mod;
    y >>= 1;
  }
  return ans;
}
long long mod_inverse(long long x) { return bp(x, mod - 2); }
long long gcd(long long a, long long b) {
  while (b) {
    a %= b;
    swap(a, b);
  }
  return a;
}
long long max(long long a, long long b) {
  if (a < b) swap(a, b);
  return a;
}
long long min(long long a, long long b) {
  if (a > b) swap(a, b);
  return a;
}
long long countSetBits(long long n) {
  long long count = 0;
  while (n) {
    count += n & 1;
    n >>= 1;
  }
  return count;
}
void solve() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n], b[n];
    for (long long i = 0; i < n; i++) cin >> a[i];
    for (long long i = 0; i < n; i++) cin >> b[i];
    if (n % 2 == 1 && a[n / 2] != b[n / 2]) {
      cout << "No" << endl;
      continue;
    }
    map<pair<long long, long long>, long long> m;
    for (long long i = 0; i < n / 2; i++) {
      m[make_pair(min(a[i], a[n - 1 - i]), max(a[i], a[n - 1 - i]))]++;
    }
    long long flag = 0;
    for (long long i = 0; i < n / 2; i++) {
      pair<long long, long long> p = {min(b[i], b[n - 1 - i]),
                                      max(b[i], b[n - 1 - i])};
      if (m[p] <= 0) {
        flag = 1;
        break;
      }
      m[p]--;
    }
    if (flag == 1)
      cout << "No" << endl;
    else
      cout << "yes" << endl;
  }
}
signed main() { solve(); }
