#pragma GCC optimize("Ofast") #include using namespace std; typedef long long int ll; typedef unsigned long long ull; mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count()); ll myRand(ll B) { return (ull)rng() % B; } inline double time() { return static_cast(chrono::duration_cast(chrono::steady_clock::now().time_since_epoch()).count()) * 1e-9; } int main() { cin.tie(nullptr); ios::sync_with_stdio(false); int q; cin >> q; while (q--) { int n; cin >> n; string s; cin >> s; auto slv = [](int n, string s) -> bool { bool chg = false; while (1) { chg = false; for (int i = 0; i < n; ++i) { if (s[i] == '?') continue; if (s[i] == s[(i+1)%n]) { if (s[(i+2)%n] == s[i]) return false; if (s[(i+2)%n] == '?') { chg = true; } s[(i+2)%n] = (s[i]^1); } if (s[i] == s[(i+2)%n] and s[(i+1)%n] == '?') { if (s[(i+1)%n] == '?') { chg = true; } s[(i+1)%n] = (s[i]^1); } } if (!chg) break; } return true; }; if (slv(n, s)) { cout << "Yes" << "\n"; } else { cout << "No" << "\n"; } } }