#pragma GCC target("avx") #pragma GCC optimize("O3") #pragma GCC optimize("unroll-loops") #include using namespace std; using ld = long double; const vector dx = {0, 0, 1, -1}; const vector dy = {1, -1, 0, 0}; #define vec vector #define int long long #define double long double //cout< #define pq priority_queue signed main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t;cin>>t; rep(i,t){ int n;cin>>n; deque A; set S; rep(i,n){ int a; cin>>a;S.insert(a); A.push_back(a); } if(*S.begin()==1){cout<<"No\n";continue;} bool f=true; n=A.size(); if(A[0]==1){ if(A[n-1]==2&&A[1]==2){f=false;} if(A[n-1]==0&&A[1]==0){f=false;} } if(A[0]==0){ if(A[n-1]==0||A[1]==0){f=false;} } if(A[0]==2){ if(A[n-1]==2||A[1]==2){f=false;} } int pos=A[0]; for(int i=1;i