#include <bits/stdc++.h>
using namespace std;
const int N = 505;
int T, n, a[N], b[N];
map<pair<int, int>, int> mp;
int main() {
  scanf("%d", &T);
  while (T--) {
    mp.clear();
    int flag = 1;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++) scanf("%d", &a[i]);
    for (int i = 1; i <= n; i++) scanf("%d", &b[i]);
    for (int i = 1; i <= n; i++) mp[make_pair(a[i], a[n - i + 1])] += 2;
    for (int i = 1; i <= n; i++) {
      if (mp[make_pair(b[i], b[n - i + 1])] == 0) {
        puts("no");
        flag = 0;
        break;
      }
      mp[make_pair(b[i], b[n - i + 1])] -= 2;
    }
    if (flag) puts("yes");
  }
  return 0;
}
