#include<iostream>
#define ll long long
#include<vector>
#include<climits>
#include<string>
#include<algorithm>
using namespace std;
void solve()
{
string pass;
cin >> pass;
if (pass.length() < 10)
{
cout << "NO
";
}
else
{
ll l, u, d, sp;
l = u = d = sp = 0;
for (ll i = 0; i < pass.length(); i++)
{
if (pass[i] >= 97 && pass[i] <= 122)
{
l++;
}
if (i > 0 && i < pass.length() - 1)
{
if (pass[i] >= '0' && pass[i] <= '9')
d++;
if (pass[i] >= 65 && pass[i] <= 90)
u++;
if (pass[i] == '@' || pass[i] == '#' || pass[i] == '%' || pass[i] == '&' || pass[i] == '?')
sp++;
}
}
if (l > 0 && u > 0 && d > 0 && sp > 0)
{
cout << "YES
";
}
else
{
cout << "NO
";
}
}
}
int main()
{
int t;
cin >> t;
while (t--)
{
solve();
}
return 0;
}