#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){ int N; cin>>N; vector<int>A(N*2); for(int &i:A)cin>>i; vector<int>cnt(N); for(int i=0;i<N*2;i++){ ++cnt[A[i]-1]; } bool ans=true; for(int i=0;i<N;i++){ if(cnt[i]!=2)ans=false; } if(A[0]!=1||A[N*2-1]!=N)ans=false; for(int i=1;i<N*2-1;i++){ if(abs(A[i]-A[i-1])!=1&&abs(A[i]-A[i-1])!=N-1||abs(A[i]-A[i+1])!=1&&abs(A[i]-A[i+1])!=N-1)ans=false; } cout<<(ans?"Yes\n":"No\n"); } }