In the previous question , Pile The password set is ‘MAKIKAWAYI’ , Sensen thinks the password is too simple , So tell Pile, How to set a secure password . What kind of password is safe ? Generally speaking, a more secure password should meet at least the following two conditions :
(1). Password length is greater than or equal to 8 , And don't exceed 16.
(2). The characters in the password should come from “ Character category ” At least three of the four groups .
The four character categories are :
1. Capital :A,B,C…Z;
2. Lowercase letters :a,b,c…z;
3. Numbers :0,1,2…9;
4. Special symbols :~,!,@,#,$,%,^;
But there are too many rules , Sensen is also a little confused . So she gave you a password , She wants to ask you if the password is secure .
The first line of input data contains a number M (M ≤ 50) , And then there's M That's ok , One password per line ( The maximum possible length is 50 ), The password only includes the above four types of characters .
For each test case , Judge whether this password is a secure password , Yes, output YES , Otherwise output NO .
3
a1b2c3d4
[email protected]
^~^@^@!%
NO
YES
NO
num=int(input())
for i in range(0,num):
str=input()
if((len(str)<8)|(len(str)>16)):
print("NO")
continue
else:
kind=[0,0,0,0]
for c in range(0,len(str)):
if(str[c].isdigit()):
kind[0]=1
if(sum(kind)>=3):
print("YES")
break
elif(str[c].isupper()):
kind[1]=1
if (sum(kind) >= 3):
print("YES")
break
elif(str[c].islower()):
kind[2]=1
if (sum(kind) >= 3):
print("YES")
break
else:
kind[3]=1
if (sum(kind) >= 3):
print("YES")
break
if(c==(len(str)-1)):
print("NO")