#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++) { ll x = i; ll y = (i + 1) % n; ll lf = (x + n - 1) % n; ll rt = (y + 1) % n; if (ch[x] == ch[y] && (ch[y] != '?')) { ll res = ch[y] - '0'; res ^= 1; char c = res + '0'; if (ch[lf] == '?') { ch[lf] = c; } else { if (ch[lf] == ch[x]) { f = 0; break; } } if (ch[rt] == '?') { ch[rt] = c; } else { if (ch[rt] == ch[y]) { f = 0; break; } } } } for (ll i = n - 1;i >= 0;i--) { ll x = i; ll y = (i + n - 1) % n; ll lf = (y + n - 1) % n; ll rt = (x + 1) % n; if (ch[x] == ch[y] && (ch[y] != '?')) { ll res = ch[y] - '0'; res ^= 1; char c = res + '0'; if (ch[lf] == '?') { ch[lf] = c; } else { if (ch[lf] == ch[x]) { f = 0; break; } } if (ch[rt] == '?') { ch[rt] = c; } else { if (ch[rt] == ch[y]) { f = 0; break; } } } } if (f) { printf("Yes\n"); } else { printf("No\n"); } } int main() { scanf("%lld",&tt); while(tt) { solve(); tt--; } return 0; }