/* -*- coding: utf-8 -*- * * 3823.cc: No.3823 Make 1 - yukicoder */ #include #include using namespace std; /* constant */ const int MAX_N = 100000; /* typedef */ /* global variables */ char s[MAX_N + 4]; /* subroutines */ /* main */ int main() { int tn; scanf("%d", &tn); while (tn--) { int n; scanf("%d%s", &n, s); if (n == 1) { if (s[0] == '1') puts("Yes"); else puts("No"); continue; } int sum = 0; for (int i = 0; i < n; i++) sum += (s[i] - '0') + 1; if (sum % 3 == 2) { bool ok = false; for (int i = 0; ! ok && i + 1 < n; i++) ok = (s[i] == s[i + 1]); if (ok) { puts("Yes"); continue; } } puts("No"); } return 0; }