#include <bits/stdc++.h>
using namespace std;
long long N, M, K, R, A, B, X, Y, Z, C, D, Q, a, b, c, d, i, j, k, first;
bool dfs(vector<vector<char> > &A, vector<vector<bool> > &vis, long long rw,
         long long cl, long long N, long long M) {
  if (rw == N - 1 && cl == M - 1) return true;
  bool p = false;
  vis[rw][cl] = true;
  if (rw + 1 < N && !vis[rw + 1][cl] &&
      (A[rw + 1][cl] == '.' || A[rw + 1][cl] == 'G'))
    p |= dfs(A, vis, rw + 1, cl, N, M);
  if (p) return true;
  if (cl + 1 < M && !vis[rw][cl + 1] &&
      (A[rw][cl + 1] == '.' || A[rw][cl + 1] == 'G'))
    p |= dfs(A, vis, rw, cl + 1, N, M);
  if (p) return true;
  if (rw > 0 && !vis[rw - 1][cl] &&
      (A[rw - 1][cl] == '.' || A[rw - 1][cl] == 'G'))
    p |= dfs(A, vis, rw - 1, cl, N, M);
  if (p) return true;
  if (cl > 0 && !vis[rw][cl - 1] &&
      (A[rw][cl - 1] == '.' || A[rw][cl - 1] == 'G'))
    p |= dfs(A, vis, rw, cl - 1, N, M);
  if (p) return true;
  return p;
}
void solve() {
  long long N;
  cin >> N;
  long long 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];
  map<pair<long long, long long>, long long int> M;
  bool p = true;
  for (long long int i = 0; i < N; i++) {
    M[{A[i], A[N - 1 - i]}]++;
  }
  for (long long int i = 0; i < N; i++) {
    if (M.find({B[i], B[N - 1 - i]}) == M.end() || M[{B[i], B[N - 1 - i]}] == 0)
      p = 0;
    else
      M[{B[i], B[N - 1 - i]}]--;
  }
  if (p)
    cout << "Yes" << '\n';
  else
    cout << "No" << '\n';
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  long long t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
