#include <bits/stdc++.h>
using namespace std;
void c_p_c() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
}
int32_t main() {
  c_p_c();
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    vector<long long int> a(n), b(n);
    for (long long int i = 0; i < (long long int)n; i++) cin >> a[i];
    for (long long int i = 0; i < (long long int)n; i++) cin >> b[i];
    if (n % 2) {
      if (a[n / 2] != b[n / 2]) {
        cout << "No\n";
        continue;
      }
    }
    map<pair<long long int, long long int>, long long int> m;
    for (long long int i = 0; i < n / 2; i++) {
      long long int temp1 = min(a[i], a[n - 1 - i]);
      long long int temp2 = max(a[i], a[n - 1 - i]);
      m[make_pair(temp1, temp2)]++;
    }
    long long int flag = 1;
    for (long long int i = 0; i < n / 2; i++) {
      long long int temp1 = min(b[i], b[n - 1 - i]);
      long long int temp2 = max(b[i], b[n - 1 - i]);
      m[make_pair(temp1, temp2)]--;
      if (m[make_pair(temp1, temp2)] == -1) flag = 0;
    }
    if (flag)
      cout << "Yes\n";
    else
      cout << "No\n";
  }
  cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC
       << "ms\n";
  return 0;
}
