#include using namespace std; #define rep(i, n) for (int i = 0; i < int(n); i++) #define per(i, n) for (int i = (n)-1; 0 <= i; i--) #define rep2(i, l, r) for (int i = (l); i < int(r); i++) #define per2(i, l, r) for (int i = (r)-1; int(l) <= i; i--) #define MM << " " << #define pb push_back #define eb emplace_back #define all(x) begin(x), end(x) #define rall(x) rbegin(x), rend(x) // #define sz(x) (int)x.size() template void print(const vector &v) { int n = v.size(); for (int i = 0; i < n; i++) cout << v[i] << (i == n - 1 ? '\n' : ' '); if (v.empty()) cout << '\n'; } template using MaxHeap = priority_queue; template using MinHeap = priority_queue, greater>; using ll = long long; using pii = pair; using pll = pair; template bool chmax(T &x, const T &y) { return (x < y) ? (x = y, true) : false; } template bool chmin(T &x, const T &y) { return (x > y) ? (x = y, true) : false; } bool solve() { int n; cin >> n; string s; cin >> s; s += s; vector c(n); rep(i, n) { if(s[i + 1] == s[i + 2] && s[i + 1] != '?') { if(s[i] == '?') c[i] |= (s[i + 1] - '0' + 1); int j = i + 3; if(n <= j) j -= n; if(s[j] == '?') c[j] |= (s[i + 1] - '0' + 1); if(s[i + 2] == s[i + 3]) c[i] += 4; } } return all_of(all(c), [](int x) { return x < 3;}); } int main() { int t; cin >> t; rep(i, t) cout << ((solve()) ? "Yes" : "No") << endl; }