#include<bits/stdc++.h>usingnamespace std;intmain(){int m, n;char s[100];
cin >> m >> n;for(int i =0; i < m; i++){int top =-1;
cin >> s;int j =0;int flag =1;while(s[j]!='\0'){if(s[j]=='S'){if(top == n -1){
flag =0;break;}else
top++;}elseif(s[j]=='X'){if(top ==-1){
flag =0;break;}else
top--;}
j++;}if(flag ==1&& top ==-1)
cout <<"YES"<< endl;else
cout <<"NO"<< endl;}return0;}