#include #include #include using namespace std; void solve() { int n; string s; cin >> n >> s; int now = 1, f = 1; while (now < n) { now <<= 1; f ^= 1; } now <<= 1; f ^= 1; int cnt[2] = {0, 0}; for (auto c : s) ++cnt[c - '0']; int check = 0; for (int i = 0; i < n - 1; ++i) if (s[i] == s[i + 1]) check = 1; now -= cnt[f] + 2 * cnt[1 ^ f]; cout << (now % 3 == 0 && check ? "Yes" : "No") << endl; } int main() { int t; cin >> t; while (t--) solve(); }