#include <iostream> #include <vector> int main() { int t; std::cin >> t; while (t--) { int n; std::cin >> n; std::string s; std::cin >> s; auto ws = std::vector<int>{}; for (int i = 0; i < 2*n; i++) { if (s[i] == 'W') ws.push_back(i); } int idx = 0; for (int i = 0; i < n; i++) { // we want to pair with next white if (s[i] == 'W') { if (ws[idx] == i) { idx += 1; } else { continue; } } if (idx >= n) { std::cout << "NO\n"; goto next; } // std::cout << "pairing " << i << " with " << ws[idx] << '\n'; idx += 1; } std::cout << "YES\n"; next:; } }