#include #include #include #include #include #include #include #include #include #include #define ll long long #define db double using namespace std; const ll N = 2e5 + 100; ll tt,n; char ch[N]; void solve() { scanf("%lld",&n); scanf("%s",ch); bool f = 1; for (ll i = 0;i < n;i++) { bool fg[5]; fg[0] = 1; fg[1] = 1; ll lf = (i + n - 1) % n; ll lfw = (i + n - 2) % n; ll rt = (i + n + 1) % n; ll rtw = (i + n + 2) % n; if (ch[i] != '?' && (ch[i] == ch[lf]) && (ch[i] == ch[rt])) { f = 0; break; } if (ch[i] != '?') { continue; } if (ch[lf] == ch[rt] && (ch[lf] != '?')) { ll x = ch[lf] - '0'; fg[x] = 0; } if (ch[lf] == ch[lfw] && (ch[lf] != '?')) { ll x = ch[lf] - '0'; fg[x] = 0; } if (ch[rt] == ch[rtw] && (ch[rt] != '?')) { ll x = ch[rt] - '0'; fg[x] = 0; } if ((!fg[0]) && (!fg[1])) { f = 0; break; } if ((fg[0]) && (fg[1])) { if ((ch[rt] != '?')) { ll x = ch[rt] - '0'; fg[x] = 0; } } if (fg[0]) { ch[i] = '0'; } else { ch[i] = '1'; } } if (f) { printf("Yes\n"); } else { printf("No\n"); } } int main() { scanf("%lld",&tt); while(tt) { solve(); tt--; } return 0; }