#include<iostream> using namespace std; int main(){ int m,i,len; char psw[55]; scanf("%d",&m); getchar(); while(m--){ int test[4]={0,0,0,0}; gets(psw); len=strlen(psw); if(len>=8&&len<=16){ for(i=0;i<len;i++){ if(psw[i]>=65&&psw[i]<=90) test[0]=1; else if(psw[i]>=97&&psw[i]<=122) test[1]=1; else if(psw[i]>=48&&psw[i]<=57) test[2]=1; else if(psw[i]=='~'||psw[i]=='!'||psw[i]=='@'||psw[i]=='#'||psw[i]=='$'||psw[i]=='%'||psw[i]=='^') test[3]=1; } if(test[0]+test[1]+test[2]+test[3]>=3) printf("YES\n"); else printf("NO\n"); } else printf("NO\n"); } return 0; }