#include<iostream>
using namespace std;
int main()
{
int n,i=0,j,b,c,d,e,k;char a[55];
cin>>n;
while(i<n)
{
b=0,c=0,d=0,e=0;
getchar(); gets(a);k=strlen(a);
for(j=0;a[j]<k;j++)
{ if(a[j]>='a'&&a[j]<='z')
b=1;
else if(a[j]>='A'&&a[j]<='Z')
c=1;
else if(a[j]>=0&&a[j]<=9)
d=1;
else
if(a[j]=='~'||a[j]=='!'||a[j]=='@'||a[j]=='#'|| a[j]=='$'|| a[j]=='%'||a[j]=='^')
e=1;}
if(e+b+c+d>=3&&j>=7&&j<=15)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
i++;
}
return 0;
}