#include<stdio.h>

#include<string.h>

int main()
{
    int n = 0;
    while (scanf("%d", &n) != EOF)
    {
        for (int i = 0; i < n; i++)
        {
            char password[101] = {0};
            scanf("%s", password);
            int capital = 0;//大写
            int number = 0;//数字
            int lower = 0;//小写
            int other =0;//其他
            if (password[0] >= '0' && password[0] <= '9')//开头不能是数字
            {
                printf("NO\n");
                continue;
            }
            if (strlen(password) < 8)//密码长度至少为8
            {
                printf("NO\n");
                continue;
            }
            for (int j = 0; password[j] != '\0'; j++)
            {
                if (password[j] >= '0' && password[j] <= '9')
                {
                    number++;
                }
                else if (password[j] >= 'a' && password[j] <= 'z')
                {
                    lower++;
                }
                else if (password[j] >= 'A' && password[j] <= 'Z')
                {
                    capital++;
                }
                else
                {
                    other++;
                }
            }
            if (other != 0)//密码只能由大小写字母和数字
            {
                printf("NO\n");
                continue;
            }
            if (number + lower + capital < 2)//密码有两种
            {
                printf("NO\n");
                continue;
            }
            printf("YES\n");
        }

    }
    return 0;
}