#include <bits/stdc++.h> using namespace std; typedef long long ll; int main() { int qq; cin >> qq; while(qq--) { int n; string str; cin >> n >> str; int k = 0; for(int i = 0;i<n;i++) k+=(str[i]=='W'); if(k&1) { cout << "NO\n"; continue; } k/=2; int len1 = 0, len2 = 0; bool ok = 1; for(int i = 0;i<n;i++) { if(str[i]=='W') { if(len1<k) len1++; else len2++; } else { if(len1<k) { ok=0; break; } len1++; } } if(!ok) { cout << "NO\n"; continue; } int totw = 0; for(int i = 0;i<n;i++) totw+=(str[i]=='W'); for(int i = n;i<2*n;i++) { if(str[i]=='W') { assert(len1>len2); totw++; len2++; if(totw==n) { break; } } else { len1++; } } ok&=(len1<=n); cout << (ok?"YES":"NO") << "\n"; } return 0; }