#include<iostream>
#include<queue>
#include<stack>
#include<deque>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<iomanip>
#include<map>
#include<set>
#include<bitset>
#define ll long long
#define T int t; cin>>t; while(t--)
#define pb push_back
#define vv vector
#define ss string
#define so(vec) sort(vec.begin(), vec.end())
#define srt(vec) sort(vec.rbegin(), vec.rend())
#define s(s) sort(s.begin(), s.end())
#define all(vec) vec.begin(), vec.end()
#define sor(arr,n) sort(arr, arr+n)
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define Mod 10000000007
const double PI = 3.14159265358979323846;
using namespace std;
void HaiDO0da() {
ios_base::sync_with_stdio(false);
cout.tie(NULL);
cin.tie(NULL);
}
int main()
{
/////////////////////// Kendeine inan ve hep mutlu ol//////////////////////////////
HaiDO0da();
// freopen("hello.in", "r", stdin);
T{
int n,f=1; cin>>n;
ss x; cin>>x;
vector<pair<char, int>>vec(130);
for (int i = 0; i < n; i++) {
if (vec[x[i]].second == 0) {
if (i % 2 == 0) {
vec[x[i]].second = 1;
}
else
vec[x[i]].second = 2;
}
}
for (int i = 1; i < n; i++) {
if (vec[x[i]].second == vec[x[i-1]].second) {
f = false;
break;
}
}
if (f) yes;
else no;
}
}
1529A - Eshag Loves Big Arrays | 19. Remove Nth Node From End of List |
925. Long Pressed Name | 1051. Height Checker |
695. Max Area of Island | 402. Remove K Digits |
97. Interleaving String | 543. Diameter of Binary Tree |
124. Binary Tree Maximum Path Sum | 1465. Maximum Area of a Piece of Cake After Horizontal and Vertical Cuts |
501A - Contest | 160A- Twins |
752. Open the Lock | 1535A - Fair Playoff |
1538F - Interesting Function | 1920. Build Array from Permutation |
494. Target Sum | 797. All Paths From Source to Target |
1547B - Alphabetical Strings | 1550A - Find The Array |
118B - Present from Lena | 27A - Next Test |
785. Is Graph Bipartite | 90. Subsets II |
1560A - Dislike of Threes | 36. Valid Sudoku |
557. Reverse Words in a String III | 566. Reshape the Matrix |
167. Two Sum II - Input array is sorted | 387. First Unique Character in a String |