#include <bits/stdc++.h> using namespace std; #define nl "\n" #define nf endl #define ll long long #define pb push_back #define _ << ' ' << int main() { ios::sync_with_stdio(0); cin.tie(0); ll t; cin >> t; while (t--) { ll n; cin >> n; n *= 2; string s; cin >> s; vector<ll> pos_w, pos_r; for (ll i = 0; i < n; i++) { if (s[i] == 'W') pos_w.pb(i); else pos_r.pb(i); } ll ans = 0; for (ll len = 1; len <= n / 2; len++) { ll flag = 1; vector<ll> left, right; string curr = s; merge(pos_w.begin(), pos_w.begin() + len, pos_r.begin(), pos_r.begin() + n / 2 - len, back_inserter(left)); merge(pos_w.begin() + len, pos_w.end(), pos_r.begin() + n / 2 - len, pos_r.end(), back_inserter(right)); assert(left.size() == n / 2 && right.size() == n / 2); /* cout << "len =" _ len << nf; for (auto u : left) cout << u << ' '; cout << nl; for (auto u : right) cout << u << ' '; cout << nl; */ for (ll i = 0; i < n / 2; i++) { if (left[i] > right[i]) flag = 0; swap(curr[left[i]], curr[right[i]]); } // cout << "curr =" _ curr << nl; for (ll i = 0; i < n / 2; i++) { if (curr[i] == 'R') flag = 0; } if (flag == 1) ans = 1; } if (ans == 1) cout << "YES" << nl; else cout << "NO" << nl; } }