#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const long long mod = 1e9 + 7;
const long long maxn = 1e6 + 10;
long long p[2] = {1000000007, 998244353};
long long seed[2] = {500000004, 500000004};
int tt, n, m;
int a[505], b[505], used[505];
int c[505], d[505];
int main() {
  scanf("%d", &tt);
  while (tt--) {
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for (int i = 1; i <= n; i++) {
      used[i] = 0;
      c[i] = a[i];
      d[i] = b[i];
    }
    sort(c + 1, c + 1 + n);
    sort(d + 1, d + 1 + n);
    int ls = 0;
    for (int i = 1; i <= n; i++)
      if (c[i] != d[i]) {
        ls = 1;
        break;
      }
    if (ls || (n & 1 && a[n / 2 + 1] != b[n / 2 + 1])) {
      printf("No\n");
      continue;
    }
    int ok_cnt = 0;
    for (int i = 1; i <= n / 2; i++) {
      for (int j = 1; j <= n / 2; j++) {
        if (used[j]) continue;
        if ((a[i] == b[j] && a[n - i + 1] == b[n - j + 1]) ||
            (a[i] == b[n - j + 1] && a[n - i + 1] == b[j])) {
          used[j] = 1;
          ok_cnt++;
          break;
        }
      }
    }
    if (ok_cnt == n / 2)
      printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
