// #include "atcoder/all" #include using ll = long long; const int MOD1000000007 = 1000000007; const int MOD998244353 = 998244353; const double PI = 3.14159265358979323846264338327950288; void solve(); int main() { std::ios_base::sync_with_stdio(false); // std::cin.tie(0); #ifdef LOCAL freopen("input.txt", "r", stdin); #endif // freopen("input.txt", "r", stdin); // freopen("output.txt", "w", stdout); int testcase; scanf("%d", &testcase); // std::cin >> testcase; while (testcase--) solve(); return 0; } const int N = 1e5 + 5; char ch[N]; bool check(std::string s) { int cnt = 0; cnt |= 1 << (((s[0] - '0') * 2 + (s[1] - '0'))); for (int j = 2; j < s.size(); j++) { int nxt = 0; for (int pre = 0; pre < 4; pre++) { if ((cnt >> pre) & 1) { int p1 = pre / 2; int p2 = pre % 2; if (s[j] == '0' || s[j] == '?') { if (pre > 0) { nxt |= (1 << (p2 * 2)); } } if (s[j] == '1' || s[j] == '?') { if (pre != 3) { nxt |= (1 << (p2 * 2 + 1)); } } } } cnt = nxt; } return cnt > 0; } void solve() { int n; scanf("%d", &n); scanf("%s", ch); std::string s = ch; bool ok = false; if ((s[0] == '?' || s[0] == '0') && (s[1] == '?' || s[1] == '0')) ok |= check("00" + s.substr(2) + "00"); if ((s[0] == '?' || s[0] == '0') && (s[1] == '?' || s[1] == '1')) ok |= check("01" + s.substr(2) + "01"); if ((s[0] == '?' || s[0] == '1') && (s[1] == '?' || s[1] == '0')) ok |= check("10" + s.substr(2) + "10"); if ((s[0] == '?' || s[0] == '1') && (s[1] == '?' || s[1] == '1')) ok |= check("11" + s.substr(2) + "11"); if (ok) printf("Yes\n"); else printf("No\n"); }