#include using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int T; cin>>T; while(T--){ int N; cin>>N; string S; cin>>S; bool ok=false; for(int gh=0;gh<4;gh++){ if((gh&2)==0&&S[0]=='1')continue; if((gh&2)==2&&S[0]=='0')continue; if((gh&1)==0&&S[1]=='1')continue; if((gh&1)==1&&S[1]=='0')continue; arraydp; for(int i=0;i<4;i++){dp[i]=false;} dp[gh]=true; for(int i=0;idp2={false,false,false,false}; switch(S[(i+2)%N]){ case '?':{ dp2[0]=dp[2]; dp2[1]=(dp[0]||dp[2]); dp2[2]=(dp[1]||dp[3]); dp2[3]=dp[1]; break; } case '1':{ dp2[1]=(dp[0]||dp[2]); dp2[3]=dp[1]; break; } case '0':{ dp2[0]=dp[2]; dp2[2]=(dp[1]||dp[3]); } } dp=dp2; } if(dp[gh]){ ok=true; } } cout<<(ok?"Yes\n":"No\n"); } }