#include <bits/stdc++.h> using namespace std; #define rep(i, a, b) for (int i = (a); i < (b); i++) #define all(x) begin(x), end(x) #define sz(x) int((x).size()) using ll = long long; using pii = pair<int, int>; using vi = vector<int>; #ifdef LOCAL auto operator<<(auto& o, auto x) -> decltype(x.first, o); auto operator<<(auto& o, auto x) -> decltype(x.end(), o) { o << "{"; for (int i = 0; auto y : x) o << ", " + !i++ * 2 << y; return o << "}"; } auto operator<<(auto& o, auto x) -> decltype(x.first, o) { return o << "(" << x.first << ", " << x.second << ")"; } void __print(auto... x) { ((cerr << x << " "), ...) << endl; } #define debug(x...) __print("[" #x "]:", x) #else #define debug(...) 2137 #endif void solve() { int n; cin >> n; string s; cin >> s; vector<int> a, b, v; for(int i = 0; i < n; i++) { if(s[i] == 'W') v.push_back(i); else a.push_back(i); } for(int i = n; i < 2 * n; i++) { if(s[i] == 'W') b.push_back(i); } if(v.size() & 1) cout << "NO\n"; else { for(int i = 0; 2 * i < v.size(); i++) { a.push_back(i); b.push_back(v[v.size() - 1 - i]); } sort(all(a)); sort(all(b)); // debug(a); // debug(b); for(int i = 0; i < a.size(); i++) { // debug(s, a[i], b[i]); swap(s[a[i]], s[b[i]]); } // debug(s); for(int i = 0; i < n; i++) { if(s[i] != 'W') { cout << "NO\n"; return; } } cout << "YES\n"; } } int main() { cin.tie(0)->sync_with_stdio(0); int t; cin >> t; while(t--) solve(); }