#include <bits/stdc++.h>
using namespace std;
const int N = 1e6;
int num1[N], num2[N];
map<pair<int, int>, int> vis;
int main() {
  int t;
  cin >> t;
  while (t--) {
    vis.clear();
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) cin >> num1[i];
    for (int i = 1; i <= n; i++) cin >> num2[i];
    for (int i = 1; i <= n / 2; i++) {
      int a = num1[i], b = num1[n - i + 1];
      if (a > b) swap(a, b);
      vis[make_pair(a, b)]++;
    }
    if (n & 1) {
      if (num1[n / 2 + 1] != num2[n / 2 + 1]) {
        cout << "no" << endl;
        continue;
      }
    }
    bool f = 1;
    for (int i = 1; i <= n / 2; i++) {
      int a = num2[i], b = num2[n - i + 1];
      if (a > b) swap(a, b);
      if (vis[make_pair(a, b)] == 0) {
        cout << "no" << endl;
        f = 0;
        break;
      }
      vis[make_pair(a, b)]--;
    }
    if (f) cout << "yes" << endl;
  }
}
