#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <string.h>

using namespace std;
#define all(v) (v.begin()), (v.end())

int main()
{
    int t;
    cin >> t;
    while (t--)
    {
        int n;
        string str;
        cin >> n >> str;

        int multiplier = 0;

        for (int i = 0; i < n; i++)
        {
            char current = str[i];
            if (multiplier == 0)
            {
                multiplier = 1;
            }
            else
            {
                multiplier = 0;
            }
            for (int j = 0; j < n; j++)
            {
                if (str[j] == current)
                {
                    str[j] = multiplier + '0';
                }
            }
        }
        for (int j = 0; j < n - 1; j++)
        {
            if (str[j] == str[j + 1])
            {
                cout << "NO" << endl;
                break;
            }
            if (j == n - 2)
            {
                cout << "YES" << endl;
            }
        }
        if (n == 1)
        {
            cout << "YES" << endl;
        }
    }
}