#include <bits/stdc++.h>
using namespace std;
const long long MAX = 1e5 + 99;
const long long INF = 1e12;
const long long mod = 1e9 + 7;
bool ok;
long long N, arr[MAX], arr2[MAX], mark[MAX];
signed main() {
  ios_base::sync_with_stdio(false);
  long long tc;
  cin >> tc;
  while (tc--) {
    ok = true;
    cin >> N;
    for (long long A = 1; A <= N; A++) {
      mark[A] = 1;
      cin >> arr[A];
    }
    for (long long A = 1; A <= N; A++) cin >> arr2[A];
    for (long long A = N / 2; A >= 1; A--) {
      ok = false;
      for (long long B = N / 2; B >= 1; B--) {
        if (!mark[B]) continue;
        if ((arr[B] == arr2[A] and arr[N - B + 1] == arr2[N - A + 1]) or
            (arr[B] == arr2[N - A + 1] and arr[N - B + 1] == arr2[A])) {
          ok = true;
          mark[B] = 0;
          break;
        }
      }
      if (ok == false) break;
    }
    if (N % 2) {
      if (arr[(N - 1) / 2 + 1] != arr2[(N - 1) / 2 + 1]) ok = false;
    }
    if (ok == true)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  return 0;
}
