#include <bits/stdc++.h>
using namespace std;
long t, n, a[505], b[505];
vector<pair<long, long> > v1, v2;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie();
  cout.tie();
  cin >> t;
  while (t--) {
    cin >> n;
    v1.clear();
    v2.clear();
    for (long i = 1; i <= n; i++) cin >> a[i];
    for (long i = 1; i <= n; i++) cin >> b[i];
    for (long i = 1; i <= n; i++) {
      v1.push_back({a[i], a[n - i + 1]});
      v2.push_back({b[i], b[n - i + 1]});
    }
    sort(v1.begin(), v1.end());
    sort(v2.begin(), v2.end());
    bool ok = 0;
    for (long i = 0; i < v1.size(); i++)
      if (v1[i] != v2[i]) ok = 1;
    if (!ok)
      cout << "yes\n";
    else
      cout << "no\n";
  }
}
