#include <bits/stdc++.h>   #define inp_out_work ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   #define testCase    int T; cin>>T; while(T--)   #define debug(P) cout<<#P<<   <<P<<endl   #define endl   n        using namespace std;       typedef long long ll;       int main() {     testCase {      int n;      cin>>n;      string s;      cin>>s;          bool poss = true;          int t = 0;          for(char x : s) {       if(x ==  T )++t;      }          if(2*(n-t) != t) {       poss = false;      }          t = 0;          for(int i = 0; i < n; ++i) {       if(s[i] ==  T ) ++t;       else {        --t;        if(t < 0) {         poss = false;         break;        }       }      }            t = 0;          for(int i = n-1; i >= 0; --i) {       if(s[i] ==  T ) ++t;       else {        --t;        if(t < 0) {         poss = false;         break;        }       }      }          if(poss) {       cout<<  YES n ;      } else {       cout<<  NO n ;      }         }   }