#include using namespace std; const int N = 100010; int n; bool dp[N][2][2]; char s[N]; void Solution() { cin >> n >> (s + 1); if (n <= 2) { cout << "Yes\n"; return; } bool ans = false; for (int l = 0; l < 2; l++) { if (s[1] != '?' && s[1] - '0' != l) continue; for (int r = 0; r < 2; r++) { if (s[2] != '?' && s[2] - '0' != r) continue; for (int i = 2; i <= n; i++) { for (int j = 0; j < 2; j++) { for (int k = 0; k < 2; k++) { dp[i][j][k] = false; } } } dp[2][l][r] = true; for (int i = 3; i <= n; i++) { for (int p = 0; p < 2; p++) { // dp[i - 1][p][j] -> dp[i][j][k] for (int j = 0; j < 2; j++) { auto upd = [&](int k) { if (j == p && j == k) return; dp[i][j][k] |= dp[i - 1][p][j]; }; if (s[i] == '?') { for (int k = 0; k < 2; k++) upd(k); } else { upd(s[i] - '0'); } } } } for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { if (!dp[n][i][j]) continue; ans |= (!(i == j && j == l) && !(j == l && l == r)); } } } } cout << (ans ? "Yes" : "No") << '\n'; } int main() { ios::sync_with_stdio(false); cin.tie(0); for (int i = 0; i < 2; i++) { for (int j = 0; j < 2; j++) { dp[0][i][j] = true; } } int testCase; cin >> testCase; while (testCase--) Solution(); return 0; }