#include <bits/stdc++.h>
using namespace std;
const long long Max = 505;
int a[Max], b[Max];
bool vis[Max];
int main() {
  std::ios::sync_with_stdio(false);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    bool flag = 0;
    map<int, int> cnt;
    for (int i = 1; i <= n; i++) vis[i] = 0;
    for (int i = 1; i <= n; i++) cin >> a[i], cnt[a[i]]++;
    for (int i = 1; i <= n; i++) cin >> b[i], cnt[b[i]]--;
    for (auto i : cnt)
      if (i.second != 0) flag = 1;
    if (flag)
      cout << "NO" << '\n';
    else {
      int mid = (n & 1) ? n / 2 + 1 : -1;
      for (int i = 1; i <= n / 2; i++) {
        bool match = 0;
        for (int j = 1; j <= n; j++) {
          if (vis[j] || j == mid) continue;
          if (a[i] == b[j] && a[n - i + 1] == b[n - j + 1]) {
            vis[j] = 1, vis[n - j + 1] = 1;
            match = 1;
            break;
          }
        }
        if (!match) flag = 1;
      }
      if (flag)
        cout << "NO" << '\n';
      else
        cout << "YES" << '\n';
    }
  }
}
