#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']; now -= cnt[f] + 2 * cnt[1 ^ f]; cout << (now % 3 == 0 ? "Yes" : "No") << endl; } int main() { int t; cin >> t; while (t--) solve(); }