#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin >> n;
string s,TF[n];
bool type = false;
for (int i = 1; i <= n; i++)
{
cin >> s;
for (int j = 0; j < s.length(); j++)
{
if (s[j] == 'D' && s[j + 1] == 'X' || s[j] == 'X' && s[j + 1] == 'D')
{
TF[i] = "Yes";
type = true;
break;
}
if (s[j] == s[j + 1] == s[j + 2] == s[j + 3])
{
TF[i] = "Yes";
type = true;
break;
}
}
if (type == false) TF[i] = "No";
type = false;
}
for (int i = 0; i < n; i++) cout << TF[i] << endl;
return 0;
}