#include <bits/stdc++.h> using namespace std; using ll = long long; const ll MOD = 1000000007; using P = pair<int,int>; #define rep(i, n) for(int i = 0; i < n; i++) #define all(x) (x).begin(),(x).end() int main(){ int t; cin >> t; rep(i,t){ int n; bool ans = true; cin >> n; vector<int> a(2*n); vector<vector<int>> ad(n); rep(j,2*n){ cin >> a[j]; a[j]--; ad[a[j]].push_back(j); if(ad[a[j]].size() > 2) ans = false; } if(!ans){ cout << "No" << endl; continue; } rep(j,n+1){ ans = true; vector<int> acopy = a; if(j<n) reverse(acopy.begin()+ad[j][0], acopy.begin()+ad[j][1]+1); rep(k,n*2) if(acopy[k] != k%n) ans = false; if(ans) break; } if(ans) cout << "Yes" << endl; else cout << "No" << endl; } return 0; }