#include <ctype.h>
#include <stdio.h>
#include <string.h>

int main() {
    int n = 0;
    int num[3] = {0};
    scanf("%d", &n);
    char arr[102];
    gets(arr);//清理缓冲区
    while(n--)
    {
        gets(arr);
        if (strlen(arr) < 8)
        {
            printf("NO\n");
        }
        else 
        {
            for (int i = 0; i < strlen(arr); i++)
            {
                if ((!isalnum(arr[i])) || (i == 0 && isdigit(arr[i])))
                {
                    printf("NO\n");
                    break;
                }
                if (isdigit(arr[i]))
                {
                    num[0] = 1;
                }
                else if(islower(arr[i]))
                {
                    num[1] = 1;
                }
                else if(isupper(arr[i]))
                {
                    num[2] = 1;
                }

            }
            if (num[0] + num[1] + num[2] >= 2)
            {
                printf("YES\n");
            }
            else 
            {
                printf("NO\n");
            }
        }
        
    }
    
    return 0;
}