#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
void solve() {
  int n;
  cin >> n;
  vi a(n), b(n);
  vector<pii> p, q;
  for (int& x : a) cin >> x;
  for (int& x : b) cin >> x;
  if (n % 2 == 1) {
    if (a[n / 2] != b[n / 2]) {
      puts("No");
      return;
    }
  }
  for (int i = 0; i < n / 2; i++) {
    p.push_back(make_pair(min(a[i], a[n - 1 - i]), max(a[i], a[n - 1 - i])));
  }
  for (int i = 0; i < n / 2; i++) {
    q.push_back(make_pair(min(b[i], b[n - 1 - i]), max(b[i], b[n - 1 - i])));
  }
  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  if (p == q) {
    puts("Yes");
  } else {
    puts("No");
  }
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int n;
  cin >> n;
  while (n--) {
    solve();
  }
}
