#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
int a[505], b[505], temp[505];
int main() {
  int i, n, t;
  scanf("%d", &t);
  while (t--) {
    scanf("%d", &n);
    for (i = 0; i < n; i++) scanf("%d", &a[i]);
    for (i = 0; i < n; i++) scanf("%d", &b[i]);
    if (n & 1 && a[n / 2] != b[n / 2])
      puts("NO");
    else {
      vector<pair<int, int>> temp, temp2;
      for (i = 0; i < n / 2; i++) {
        temp.emplace_back(min(a[i], a[n - 1 - i]), max(a[i], a[n - 1 - i]));
        temp2.emplace_back(min(b[i], b[n - 1 - i]), max(b[i], b[n - 1 - i]));
      }
      sort(temp.begin(), temp.end());
      sort(temp2.begin(), temp2.end());
      if (temp == temp2)
        puts("YES");
      else
        puts("NO");
    }
  }
}
