#include <bits/stdc++.h> #define int long long #define ll long long #define sz(x) (int)(x).size() #define all(x) begin(x),end(x) #define rep(i,a,b) for (int i=(a);i<(b);i++) using namespace std; string to_string (string s) {return s; } template <typename T> string to_string(T v) { bool first = true; string res = "["; for (const auto & x : v) { if (!first) res += ", "; first = false; res += to_string(x); } res += "]"; return res; } void dbg_out() { cout << endl;} template <typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cout << ' ' << to_string(H); dbg_out(T...); } #ifdef DEBUG #define dbg(...) cout << "(" << #__VA_ARGS__ << "):", dbg_out(__VA_ARGS__) #else #define dbg(...) #endif bool isok(int n, vector<char> ls) { int fr = -1; for (int i = 0; i < n; i++) { if (ls[i] == 'R') { fr = i; break; } } if (fr == -1) return ((n % 2) == 0); int cab = 0; for (int i = fr + 1; i < n; i++) cab += (ls[i] == 'W'); int bef = 0; for (int i = 0; i < fr; i++) bef += (ls[i] == 'W'); return (bef >= cab && (((bef - cab) % 2) == 0)); } void solve() { int n; cin >> n; vector<char> ls (2 * n); for (int i = 0; i < 2*n; i++) { cin >> ls[i]; } bool a = isok(n, ls); for (int i = 0; i < 2*n; i++) { if (ls[i] == 'W') ls[i] = 'R'; else ls[i] = 'W'; } reverse(ls.begin(), ls.end()); if (isok(n, ls) && a) { cout << "YES\n"; } else { cout << "NO\n"; } } signed main(void) { ios_base::sync_with_stdio(false); cin.tie(0); int t; cin >> t; while (t--) solve(); }