#define rep(i,n) for(int i=0;i<(int)(n);i++) #define ALL(v) v.begin(),v.end() typedef long long ll; #include using namespace std; vector> G[200200]; const double INF=1e9; int main(){ ios::sync_with_stdio(false); std::cin.tie(nullptr); int t; cin>>t; while(t--){ int n; cin>>n; vector A(n); int sum=0,c0=-1,c2=-1; rep(i,n){ cin>>A[i]; sum+=A[i]; if(A[i]==0) c0=i; if(A[i]==2) c2=i; } if(sum!=n || c0==-1 || c2==-1){ cout<<"No\n"; continue; } vector B(n+1); rep(i,n) B[i]=A[(i+c0)%n]; B[n]=B[0]; bool b=true; int now=0; for(int i=0;i