#include using namespace std; using ll = long long; #define rep(i,n) for (int i=0;i<(int)(n);i++) map,bool> mp={ {{0,0,0},0}, {{0,0,1},1}, {{0,1,0},0}, {{0,1,1},1}, {{1,0,0},1}, {{1,0,1},0}, {{1,1,0},1}, {{1,1,1},0}, {{0,0,0,0},0}, {{0,0,0,1},1}, {{0,0,1,0},0}, {{0,0,1,1},1}, {{0,1,0,0},0}, {{0,1,0,1},1}, {{0,1,1,0},1}, {{0,1,1,1},1}, {{1,0,0,0},1}, {{1,0,0,1},1}, {{1,0,1,0},1}, {{1,0,1,1},0}, {{1,1,0,0},1}, {{1,1,0,1},0}, {{1,1,1,0},1}, {{1,1,1,1},0}, }; void solve(){ int n; cin>>n; vector a(n); rep(i,n) cin>>a[i]; while(a.size()>4){ int ba=*a.rbegin(); int ba2=*(a.rbegin()+1); int ba3=*(a.rbegin()+2); if(ba==ba2) a.pop_back(); else{ if(ba2==ba3){ cout<<"Yes\n"; return; } a.pop_back(); a.pop_back(); } } if(mp[a]) cout<<"Yes\n"; else cout<<"No\n"; } int main(){ int t; cin>>t; rep(i,t) solve(); }