#include <bits/stdc++.h>
using namespace std;
long long M = 1e9 + 7;
double pi = acos(-1.0);
long long powerm(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x) % M;
    y = y >> 1;
    x = (x * x) % M;
  }
  return res % M;
}
long long power(long long x, long long y) {
  long long res = 1;
  while (y) {
    if (y & 1) res = (res * x);
    y = y >> 1;
    x = (x * x);
  }
  return res;
}
long long max3(long long a, long long b, long long c) {
  return max(max(a, b), c);
}
long long gcd(long long a, long long b) {
  if (b > a) return gcd(b, a);
  if (b == 0) return a;
  return gcd(b, a % b);
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    int a[n], b[n];
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    map<pair<int, int>, int> m;
    for (int i = 0; i < n / 2; i++) {
      int g = a[i], h = a[n - 1 - i];
      if (g > h) swap(g, h);
      m[make_pair(g, h)]++;
    }
    bool ok = 1;
    for (int i = 0; i < n / 2; i++) {
      int g = b[i], h = b[n - 1 - i];
      if (g > h) swap(g, h);
      m[make_pair(g, h)]--;
      if (m[make_pair(g, h)] < 0) {
        ok = 0;
        break;
      }
    }
    if (n & 1) {
      if (a[n / 2] != b[n / 2]) ok = 0;
    }
    if (ok)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
