#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;
const double PI = acos(-1.0);
template <typename T>
T gcd(T a, T b) {
  return (b ? __gcd(a, b) : a);
}
template <typename T>
T lcm(T a, T b) {
  return (a * b) / gcd(a, b);
}
void solve() {
  long long int n;
  cin >> n;
  vector<long long int> a(n), b(n);
  for (long long int i = 0; i < (n); ++i) {
    cin >> a[i];
  }
  for (long long int i = 0; i < (n); ++i) {
    cin >> b[i];
  }
  bool ans = true;
  if (n % 2 == 1) {
    long long int mid = (n) / 2;
    if (a[mid] != b[mid]) {
      ans = false;
    }
  }
  map<pair<long long int, long long int>, long long int> s;
  for (long long int i = 0; i < (n / 2); ++i) {
    long long int j = n - 1 - i;
    long long int x = a[i], y = a[j];
    if (x > y) swap(x, y);
    s[make_pair(x, y)]++;
  }
  for (long long int i = 0; i < (n / 2); ++i) {
    long long int j = n - 1 - i;
    long long int x = b[i], y = b[j];
    if (x > y) swap(x, y);
    if (s[make_pair(x, y)] <= 0) {
      ans = false;
      break;
    }
    s[make_pair(x, y)]--;
  }
  cout << (ans ? "yes" : "No") << "\n";
}
signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  long long int T;
  cin >> T;
  while (T-- > 0) {
    solve();
  }
  return 0;
}
