#include using namespace std; using ll=long long; int main(){ ll t; cin>>t; while(t--){ ll n; cin>>n; vector a(n); for(ll i=0;i>a[i]; } bool ok=true; for(ll i=0;i cnt(3,0); cnt[a[(i-1+n)%n]]++; cnt[a[(i+n)%n]]++; cnt[a[(i+1+n)%n]]++; if(cnt[0]==2||cnt[1]==3||cnt[2]==2){ ok=false; } } if(ok){ cout<<"Yes"<