#include <bits/stdc++.h> using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<vi> vvi; #define all(x) begin(x),end(x) #define rep(i,a,b) for(int i=(a);i<(b);++i) #define sz(x) int(x.size()) void brute(string s) { int n = s.size(); for(int i=0;i<1<<(n*2);++i) if(popcount(unsigned(i))==n) { } } void solve(){ int n; cin >> n; string s; cin >> s; int cnt = 0; int cnt2=0; vi a,b; int c= count(s.begin(),s.begin()+n,'W'); if(c%2==1) { cout << "NO\n"; return; } c/=2; for(int i=0;i<n;++i) { if(s[i]=='W') { if(c>0) { a.push_back(i); } else b.push_back(i); --c; } } for(int i=0;i<n;++i) { if(s[i]=='R') { a.push_back(i); } } c= count(s.begin()+n,s.begin()+n*2,'R')/2; for(int i=n;i<n*2;++i) { if(s[i]=='W') b.push_back(i); } for(int i=n;i<n*2;++i) { if(s[i]=='B') { if(c>0) { a.push_back(i); } else b.push_back(i); c--; } } if (is_sorted(all(a)) and is_sorted(all(b))){ cout << "YES\n"; } else{ cout << "NO\n"; } } int main() { cin.tie(NULL); cin.sync_with_stdio(false); int t; cin >> t; while(t--) solve(); }