[cpp]
#include <iostream>
#include <stdio.h>
#include <string.h>
using namespace std;
int main()
{
char a[50];
int m,k1,k2,k3,k4;
unsigned i;
cin>>m;
getchar();
while(m--)
{
k1=k2=k3=k4=0;
cin.getline(a,50);
if(strlen(a)<8||strlen(a)>16)
{
cout<<"NO"<<endl;
}
else
{
for(i=0;i<strlen(a);i++)
{
if(a[i]>='0'&&a[i]<='9')
k1=1;
if(a[i]>='a'&&a[i]<='z')
k2=1;
if(a[i]>='A'&&a[i]<='Z')
k3=1;
if(a[i]=='~'||a[i]=='!'||a[i]=='@'||a[i]=='#'||a[i]=='$'||a[i]=='%'||a[i]=='^')
k4=1;
}
if(k1+k2+k3+k4>=3)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;
}
}
return 0;
}