#include<bits/stdc++.h>
using namespace std;

int main(){
    int t;
    cin>>t;
    while(t--){
        int n;
        cin>>n;

        vector<char> v(2*n);
        vector<int> ww,rr,w,r,pos(2*n,-1);
        for(int i=0;i<2*n;i++){
            cin>>v[i];
            if(v[i]=='W'){
                if(i<n)ww.push_back(i);
                else w.push_back(i);
            }else{
                if(i<n)r.push_back(i);
                else rr.push_back(i);
            }
        }
        if(ww.size()%2!=0 || rr.size()%2!=0 || r.size()!=w.size()){
            cout<<"NO\n";
            continue;
        }
        
        for(int i=0;i<ww.size()/2;i++){
            pos[ww[i]]=ww[i+ww.size()/2];
        }
        for(int i=0;i<rr.size()/2;i++){
            pos[rr[i]]=rr[i+rr.size()/2];
        }
        for(int i=0;i<r.size();i++){
            pos[r[i]]=w[i];
        }

        int last=-1;
        bool ok =  true;
        for(int i=0;i<2*n;i++){
            if(pos[i]!=-1){
                if(pos[i]<last){
                    ok=false;
                }
                last=pos[i];
            }
        }
        cout<<(ok ? "YES" : "NO")<<"\n";
    }
}