#include <bits/stdc++.h> using namespace std; //#define int long long typedef long long ll; typedef long double ld; void solve() { int n; cin >> n; string s; cin >> s; if (s[0] == 'R') { int i = 0; while (s[i] == 'R') ++i; if (i == n) { cout << "YES\n"; } else { cout << "NO\n"; } return; } int first_r = 0; while (s[first_r] == 'W') ++first_r; if (first_r == n) { if (n % 2 == 0) { cout << "YES\n"; } else { cout << "NO\n"; } return; } vector<int> marked(2 * n, 0); int wcnt =0 ; for (int i =0; i < n; i++) { if (s[i] == 'W') wcnt++; } wcnt = wcnt / 2 + (wcnt % 2); int cur = 0; for (int i = 0; i < n; i++) { if (s[i] == 'R') { marked[i] = 1; cur++; } if (s[i] == 'W' && wcnt != 0) { wcnt--; cur++; marked[i] = 1; } } for (int i = n; i < 2 * n; i++) { if (cur == n) break; if (s[i] == 'R') { cur++; marked[i] = 1; } } vector<int> a, b; for (int i = 0; i < 2 * n; i++) { if (marked[i]) a.push_back(i); else b.push_back(i); } for (int i =0; i < n ; i++) { swap(s[a[i]], s[b[i]]); } for (int i =0; i <n; i++) { if (s[i] == 'R') { cout << "NO\n"; return; } } cout << "YES\n"; } signed main() { ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); #ifdef LC freopen("/home/team11/CLionProjects/contest/input.txt", "r", stdin); freopen("/home/team11/CLionProjects/contest/output.txt", "w", stdout); #endif int t= 1 ; cin >> t; for (int tt =0; tt <t; tt++) { solve(); } return 0; }