#include <bits/stdc++.h>
using namespace std;
const int N = 1e6 + 10;
const long long mod = 1e9 + 7;
inline long long read() {
  long long X = 0;
  bool flag = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') flag = 0;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9') {
    X = (X << 1) + (X << 3) + ch - '0';
    ch = getchar();
  }
  if (flag) return X;
  return ~(X - 1);
}
int n, m, x, k;
long long ar[N], br[N];
long long ans;
map<int, int> mp;
vector<pair<int, int>> vt1;
vector<pair<int, int>> vt2;
int main() {
  int T;
  cin >> T;
  while (T--) {
    n = read();
    bool fail = false;
    vt1.clear();
    vt2.clear();
    for (int i = 1; i <= n; i++) ar[i] = read();
    for (int i = 1; i <= n; i++) br[i] = read();
    if (n & 1 && ar[n / 2 + 1] != br[n / 2 + 1]) fail = true;
    for (int i = 1; i <= n / 2; i++) {
      int a = ar[i];
      int b = ar[n - i + 1];
      if (a > b) swap(a, b);
      vt1.push_back({a, b});
    }
    for (int i = 1; i <= n / 2; i++) {
      int a = br[i];
      int b = br[n - i + 1];
      if (a > b) swap(a, b);
      vt2.push_back({a, b});
    }
    sort(vt1.begin(), vt1.end());
    sort(vt2.begin(), vt2.end());
    if (vt1 != vt2) fail = true;
    if (fail)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
  return 0;
}
