#include <bits/stdc++.h>
using namespace std;
const int Maxn = 520;
map<int, int> id;
int a[Maxn], b[Maxn], c[Maxn];
int g[Maxn][Maxn], n;
inline int read() {
  int s = 0, w = 1;
  char ch = getchar();
  while (ch < '0' || ch > '9') {
    if (ch == '-') w = -1;
    ch = getchar();
  }
  while (ch >= '0' && ch <= '9')
    s = (s << 3) + (s << 1) + (ch ^ 48), ch = getchar();
  return s * w;
}
int main() {
  int T = read();
  while (T--) {
    n = read();
    for (int i = 1; i <= n; ++i) c[i] = a[i] = read();
    for (int i = 1; i <= n; ++i) b[i] = read();
    sort(c + 1, c + 1 + n);
    int cnt = 0;
    for (int i = 1; i <= n; ++i) {
      c[++cnt] = c[i];
      id[c[cnt]] = cnt;
      int j = i + 1;
      while (c[i] == c[j] && j <= n) ++j;
      i = j - 1;
    }
    if ((n & 1) && a[(n >> 1) + 1] != b[(n >> 1) + 1]) {
      puts("No");
      goto GG;
    }
    for (int i = 1; i <= (n >> 1); ++i) {
      int x = id[a[i]], y = id[a[n - i + 1]];
      if (x > y) swap(x, y);
      ++g[x][y];
    }
    for (int i = 1; i <= (n >> 1); ++i) {
      int x = id[b[i]], y = id[b[n - i + 1]];
      if (x > y) swap(x, y);
      if (!g[x][y]) {
        puts("No");
        goto GG;
      }
      --g[x][y];
    }
    puts("Yes");
  GG:
    memset(g, 0, sizeof(g));
    for (int i = 1; i <= n; ++i) {
      id[c[i]] = 0;
      c[i] = b[i] = a[i] = 0;
    }
  }
  return 0;
}
