#include using namespace std; void solve(){ int n, tot = 0, dif = 0; string s; cin >> n >> s; for(int i = 0; i < n; i++){ tot = (tot + (s[i] - '0' + 1)) % 3; if(i && s[i] == s[i - 1]) dif = 1; } if(tot == 2){ if(n == 1 || dif){ cout << "Yes\n"; return; } } cout << "No\n"; } int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while(t--){ solve(); } }