#include <bits/stdc++.h> using namespace std; using ll = long long; using LL = long long; using i64 = long long; void solve() { int n; cin >> n; string s; cin >> s; int correct = 0; for (int i = 0; i < n; i++) correct += s[i] == 'W'; if (correct % 2) { cout << "NO\n"; return; } vector<pair<int, int>> pairs; vector<int> cor_w, wr_w, cor_r, wr_r; for (int i = 0; i < n; i++) { if (s[i] == 'W') cor_w.push_back(i); else wr_r.push_back(i); } for (int i = n; i < 2 * n; i++) { if (s[i] == 'R') cor_r.push_back(i); else wr_w.push_back(i); } for (int i = 0; i < cor_w.size() / 2; i++) { pairs.emplace_back(cor_w[i], cor_w[i + cor_w.size() / 2]); } for (int i = 0; i < cor_r.size() / 2; i++) { pairs.emplace_back(cor_r[i], cor_r[i + cor_r.size() / 2]); } for (int i = 0; i < wr_w.size(); i++) { pairs.emplace_back(wr_r[i], wr_w[i]); } sort(pairs.begin(), pairs.end()); for (int i = 1; i < n; i++) { if (pairs[i].second < pairs[i - 1].second) return void(cout << "NO\n"); } cout << "YES\n"; } int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); int t; cin >> t; while (t--) solve(); }