#include<stdio.h>
#include<string.h>
int main()
{
int n,num1,num2,num3,num4,i;
char s[105];
while(scanf("%d",&n)!=EOF)
{
getchar();
while(n--)
{
num1=num2=num3=num4=0;
gets(s);
for(i=0;s[i];i++)
{
if(s[i]>='A'&&s[i]<='Z')
{
num1=1;
continue;
}
if(s[i]>='a'&&s[i]<='z')
{
num2=1;
continue;
}
if(s[i]>='0'&&s[i]<='9')
{
num3=1;
continue;
}
else
num4=1;
}
if(num1+num2+num3+num4>=3 && strlen(s)<=16 &&strlen(s)>=8)
printf("YES\n");
else
printf("NO\n");
}
}
return 0;
}