#include<bits/stdc++.h>
using namespace std;
int t; char s[17];
int main(){
scanf("%d",&t);
while(t--){
scanf("%s",s); bool f=0;
for(int i=0;i<strlen(s)-1;i++)
if(i+4<strlen(s))
if(s[i]==s[i+1]&&s[i+1]==s[i+2]&&
s[i+2]==s[i+3]) f=1;
else
if(s[i]=='D'&&s[i+1]=='X') f=1;
printf("%s\n",(f?"YES":"NO"));
}
return 0;
}