#include <bits/stdc++.h>
using namespace std;
int main() {
int t,n,s; cin >> t;
while(t--){
/*string s;*/ cin >> n >> s;
if(s == 0 || s == 1 || s == 10 || s == 01) cout << "YES\n";
else cout << "NO\n";
}
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgppbnQgbWFpbigpIHsKCWludCB0LG4sczsgY2luID4+IHQ7Cgl3aGlsZSh0LS0pewoJCS8qc3RyaW5nIHM7Ki8JY2luID4+IG4gPj4gIHM7CgkJaWYocyA9PSAwIHx8IHMgPT0gMSB8fCBzID09IDEwIHx8IHMgPT0gMDEpCWNvdXQgPDwgIllFU1xuIjsKCQllbHNlCWNvdXQgPDwgIk5PXG4iOwoJfQoJcmV0dXJuIDA7Cn0=