手速要快
#include<iostream>
using namespace std;
int a[100010];
int main()
{
int n,m;
string s;
cin >> n >> m;
while(n--){
bool flag = true;
int t=0;
cin >> s;
for(int i=0;i<s.size();i++){
if(s[i]=='S') ++t;
else --t;
if(t<0||t>m) {
flag=false;
break;
}
}
if(t==0&&flag) cout << "YES" << endl;
else cout << "NO" <<endl;
}
return 0;
}