#include <iostream>
#include <algorithm>
#include <cctype>
using namespace std;

bool check (int n, string s);

int main (){
    int t,n;
    string s;
    cin >> t;
    while (t--) {
        cin >> n;
        cin >> s;
        
        cout << (check(n,s) ? "yes" : "no" ) <<endl;

    }
    return 0;
}


bool check (int n, string m) {
         string s;
        s=m;
        if (n == 1) {
        return true;
        }
        replace(s.begin(),s.end(),s[0],'0');
        for (int i=1; i<n; i++){
            if (isalpha(s[i])) {

                if(i==0 || s[i-1]=='0') {
                    replace(s.begin(),s.end(),s[i],'1');
                }
                else if (s[i-1]=='1') {
                    replace(s.begin(),s.end(),s[i],'0');
                }

                }


            if (s[i] == s[i-1]) {
                return false;
            }

        }
        return true;
}