#include <algorithm> #include <cassert> #include <iostream> #include <string> #include <vector> void solve() { int n; std::cin >> n; std::string s; std::cin >> s; assert((int) s.size() == 2 * n); std::vector<int> pos1, pos2, pos3, pos4; for (int i = 0; i < n; ++i) { if (s[i] == 'R') { pos1.push_back(i); } else { pos3.push_back(i); } } for (int i = n; i < 2 * n; ++i) { if (s[i] == 'W') { pos2.push_back(i); } else { pos4.push_back(i); } } assert(pos1.size() == pos2.size()); assert(pos3.size() == pos4.size()); if ((int) pos3.size() % 2 == 1) { std::cout << "NO" << '\n'; return; } for (int i = 0; i < (int) pos3.size() / 2; ++i) { pos1.push_back(pos3[i]); pos1.push_back(pos4[i]); } for (int i = (int) pos3.size() / 2; i < (int) pos3.size(); ++i) { pos2.push_back(pos3[i]); pos2.push_back(pos4[i]); } std::sort(pos1.begin(), pos1.end()); std::sort(pos2.begin(), pos2.end()); assert((int) pos1.size() == n); assert((int) pos2.size() == n); std::vector<bool> used(2 * n, false); for (int x : pos1) used[x] = true; for (int x : pos2) used[x] = true; for (int i = 0; i < 2 * n; ++i) { assert(used[i]); } for (int i = 0; i < n; ++i) { std::swap(s[pos1[i]], s[pos2[i]]); } for (int i = 0; i < n; ++i) { if (s[i] == 'R' || s[n + i] == 'W') { std::cout << "NO" << '\n'; return; } } std::cout << "YES" << '\n'; } int main() { int t; std::cin >> t; while (t--) { solve(); } return 0; }