using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static int[] NList => ReadLine().Split().Select(int.Parse).ToArray(); static string[] SList(long n) => Enumerable.Repeat(0, (int)n).Select(_ => ReadLine()).ToArray(); public static void Main() { Solve(); } static void Solve() { var t = NN; var ans = new bool[t]; for (var u = 0; u < t; ++u) { var n = NN; var s = ReadLine(); ans[u] = Three(n, s); } WriteLine(string.Join("\n", ans.Select(f => f ? "Yes" : "No"))); } static bool Three(int n, string s) { var c = s.ToList(); c.Add(s[0]); c.Add(s[1]); for (var i = 0; i + 2 < c.Count; ++i) { if (c[i] == '0' && c[i + 1] == '0' && c[i + 2] == '?') c[i + 2] = '1'; if (c[i] == '1' && c[i + 1] == '1' && c[i + 2] == '?') c[i + 2] = '0'; } for (var i = c.Count - 3; i >= 0; --i) { if (c[i] == '?' && c[i + 1] == '0' && c[i + 2] == '0') c[i] = '1'; if (c[i] == '?' && c[i + 1] == '1' && c[i + 2] == '1') c[i] = '0'; } var len = 0; var last = 'a'; for (var i = 0; i < c.Count; ++i) { if (c[i] != last || c[i] == '?') { len = 1; last = c[i]; } else ++len; if (len == 3) { return false; } } return true; } }