#include <bits/stdc++.h>
using namespace std;
const long long N = 2e3, MOD = 998244353;
void solve() {
  int n;
  cin >> n;
  vector<int> a(n), b(n);
  map<pair<int, int>, int> mp;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  for (int i = 0; i < n; ++i) {
    cin >> b[i];
  }
  if (n % 2 == 1 && a[n / 2] != b[n / 2]) {
    cout << "No\n";
    return;
  }
  multiset<pair<int, int>> p1, p2;
  for (int i = 0; i < n / 2; ++i) {
    pair<int, int> p = {min(a[i], a[n - 1 - i]), max(a[i], a[n - 1 - i])};
    mp[p]++;
  }
  for (int i = 0; i < n / 2; ++i) {
    pair<int, int> p = {min(b[i], b[n - 1 - i]), max(b[i], b[n - 1 - i])};
    if (!mp[p]) {
      cout << "No\n";
      return;
    }
    mp[p]--;
  }
  cout << "Yes\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tt;
  cin >> tt;
  for (int tc = 1; tc <= tt; ++tc) {
    solve();
  }
}
