#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = 998244353; void solve() { int N; cin >> N; vectorA(2 * N); for (int i = 0; i < 2 * N; i++)cin >> A[i]; vectorX(2 * N); for (int i = 0; i < 2 * N; i++)X[i] = i % N + 1; vectort = X; bool ok = true; for (int j = 0; j < 2 * N; j++) { if (A[j] != X[j])ok = false; } if (ok) { cout << "Yes" << endl; return; } for (int i = 0; i < N; i++) { X = t; reverse(X.begin() + i + 1, X.begin() + N + i); ok = true; for (int j = 0; j < 2 * N; j++) { if (A[j] != X[j])ok = false; } if (ok) { cout << "Yes" << endl; return; } } cout << "No" << endl; } signed main() { ios::sync_with_stdio(false); cin.tie(0); int T; cin >> T; for (int _ = 0; _ < T; _++) { solve(); } return 0; }