var n = 0;
if((line = read_line()) != null){
    n = parseInt(line);
    while(n > 0){
        line = read_line();
    	if(line.length < 8){
        	print('NO');
        }else{
            var reg = /(^[a-z]+[0-9|A-Z]+\w+)|(^[A-Z]+[a-z|0-9]+\w+)/;
            if(reg.test(line)){
            	print('YES');
            }else{
            	print('NO');
            }
        }
        n--;
    }
}