#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;
}
}
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8YWxnb3JpdGhtPgojaW5jbHVkZSA8Y21hdGg+CiNpbmNsdWRlIDxzdGRpby5oPgojaW5jbHVkZSA8c3RyaW5nLmg+Cgp1c2luZyBuYW1lc3BhY2Ugc3RkOwojZGVmaW5lIGFsbCh2KSAodi5iZWdpbigpKSwgKHYuZW5kKCkpCgppbnQgbWFpbigpCnsKICAgIGludCB0OwogICAgY2luID4+IHQ7CiAgICB3aGlsZSAodC0tKQogICAgewogICAgICAgIGludCBuOwogICAgICAgIHN0cmluZyBzdHI7CiAgICAgICAgY2luID4+IG4gPj4gc3RyOwoKICAgICAgICBpbnQgbXVsdGlwbGllciA9IDA7CgogICAgICAgIGZvciAoaW50IGkgPSAwOyBpIDwgbjsgaSsrKQogICAgICAgIHsKICAgICAgICAgICAgY2hhciBjdXJyZW50ID0gc3RyW2ldOwogICAgICAgICAgICBpZiAobXVsdGlwbGllciA9PSAwKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBtdWx0aXBsaWVyID0gMTsKICAgICAgICAgICAgfQogICAgICAgICAgICBlbHNlCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIG11bHRpcGxpZXIgPSAwOwogICAgICAgICAgICB9CiAgICAgICAgICAgIGZvciAoaW50IGogPSAwOyBqIDwgbjsgaisrKQogICAgICAgICAgICB7CiAgICAgICAgICAgICAgICBpZiAoc3RyW2pdID09IGN1cnJlbnQpCiAgICAgICAgICAgICAgICB7CiAgICAgICAgICAgICAgICAgICAgc3RyW2pdID0gbXVsdGlwbGllciArICcwJzsKICAgICAgICAgICAgICAgIH0KICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBmb3IgKGludCBqID0gMDsgaiA8IG4gLSAxOyBqKyspCiAgICAgICAgewogICAgICAgICAgICBpZiAoc3RyW2pdID09IHN0cltqICsgMV0pCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgIk5PIiA8PCBlbmRsOwogICAgICAgICAgICAgICAgYnJlYWs7CiAgICAgICAgICAgIH0KICAgICAgICAgICAgaWYgKGogPT0gbiAtIDIpCiAgICAgICAgICAgIHsKICAgICAgICAgICAgICAgIGNvdXQgPDwgIllFUyIgPDwgZW5kbDsKICAgICAgICAgICAgfQogICAgICAgIH0KICAgICAgICBpZiAobiA9PSAxKQogICAgICAgIHsKICAgICAgICAgICAgY291dCA8PCAiWUVTIiA8PCBlbmRsOwogICAgICAgIH0KICAgIH0KfQ==