#include <bits/stdc++.h> #define X first #define Y second #define PB push_back #define x first #define y second #define pb push_back using namespace std; typedef long long ll; typedef vector<int> vi; typedef pair<int,int> pii; void solve() { int n; string s; cin >> n >> s; int cnt = 0; vector< pii > pairs; vi red, white, un; for(int i = 0;i < 2 * n;i++) { if(s[i] == 'R' && i < n) red.PB(i); else if(s[i] == 'W' && i < n) { un.PB(i); } else if(s[i] == 'W') { white.PB(i); } if(i < n) cnt += s[i] == 'W'; } if(cnt & 1) { cout << "NO\n"; return; } vector < int > L, R; for(int i = 0;i + cnt / 2 < cnt;i++) L.PB(un[i]), R.PB(un[i + cnt / 2]); for(int i = 0;i < n - cnt;i++) L.PB(min(red[i], white[i])), R.PB(max(red[i], white[i])); sort(L.begin(), L.end()); sort(R.begin(), R.end()); for(int j = 0;j < (int)L.size();j++) swap(s[L[j]], s[R[j]]); for(int i = 0;i < n;i++) { if(s[i] != 'W') { cout << "NO\n"; return; } } cout << "YES\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(0); int T; cin >> T; for(;T--;) solve(); return 0; }