#include <bits/stdc++.h>
using namespace std;
const int N = 510;
int n;
int a[N], b[N], c[N], vis[N];
void init() {
  for (int i = 0; i < n; i++) {
    a[i] = b[i] = c[i] = vis[i] = 0;
  }
}
int main() {
  int T;
  cin >> T;
  while (T--) {
    scanf("%d", &n);
    init();
    for (int i = 0; i < n; i++) scanf("%d", &a[i]);
    for (int i = 0; i < n; i++) scanf("%d", &b[i]);
    for (int i = 0; i < n / 2; i++) {
      int j = n - 1 - i;
      for (int k = 0; k < n; k++)
        if (!vis[k]) {
          if (a[i] == b[k] && a[j] == b[n - k - 1]) {
            c[k] = a[i];
            c[n - k - 1] = a[j];
            vis[k] = vis[n - k - 1] = 1;
            break;
          }
        }
    }
    bool f = true;
    if (n & 1) c[n / 2] = a[n / 2];
    for (int i = 0; i < n; i++) {
      if (b[i] != c[i]) {
        f = false;
        break;
      }
    }
    if (f)
      puts("yes");
    else
      puts("No");
  }
}
