#include <bits/stdc++.h>
using namespace std;
const int MOD = 998244353;
const int N = 5005;
const double PI = 4 * atan(1);
const double eps = 1e-7;
const long long oo = 1e10;
const int K = 205;
int t;
int n;
int a[505], b[505];
map<int, multiset<int> > ma1;
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    if (n % 2 && a[n / 2] != b[n / 2]) {
      cout << "No\n";
      continue;
    }
    ma1.clear();
    for (int i = 0; i < n / 2; i++) {
      ma1[a[i]].insert(a[n - 1 - i]);
      ma1[a[n - 1 - i]].insert(a[i]);
    }
    int cnt = 0;
    for (int i = 0; i < n / 2; i++) {
      if (ma1[b[i]].count(b[n - 1 - i])) {
        ma1[b[i]].erase(ma1[b[i]].find(b[n - 1 - i]));
        ma1[b[n - 1 - i]].erase(ma1[b[n - 1 - i]].find(b[i]));
        cnt++;
      }
    }
    if (cnt == n / 2) {
      cout << "Yes\n";
    } else {
      cout << "No\n";
    }
  }
  return 0;
}
