Read problems statements in [Hindi], [Mandarin Chinese], [Russian], [Vietnamese], and [Bengali] as well.

Chef is planning to setup a secure password for his Codechef account. For a password to be secure the following conditions should be satisfied:

1) Password must contain at least one lower case letter $[a-z]$;

2) Password must contain at least one upper case letter $[A-Z]$ strictly inside, i.e. not as the first or the last character;

3) Password must contain at least one digit $[0-9]$ strictly inside;

4) Password must contain at least one special character from the set $\{$ '@', '\#', '%', '&', '?' $\}$ strictly inside;

5) Password must be at least $10$ characters in length, but it can be longer.

Chef has generated several strings and now wants you to check whether the passwords are secure based on the above criteria. Please help Chef in doing so.

------  Input ------

First line will contain $T$, number of testcases. Then the testcases follow. 
Each testcase contains of a single line of input, string $S$. 

------  Output ------
For each testcase, output in a single line "YES" if the password is secure and "NO" if it is not.

------  Constraints  ------
$1 ≤ |S| ≤ 20$
All the characters in $S$ are one of the following: lower case letters $[a-z]$, upper case letters $[A-Z]$, digits $[0-9]$, special characters from the set $\{$ '@', '\#', '%', '&', '?' $\}$
Sum of length of strings over all tests is atmost $10^{6}$

----- Sample Input 1 ------ 
3

#cookOff#P1

U@code4CHEFINA

gR3@tPWD
----- Sample Output 1 ------ 
NO

YES

NO
----- explanation 1 ------ 
Example case 1: Condition $3$ is not satisfied, because the only digit is not strictly inside.

Example case 2: All conditions are satisfied.

Example case 3: Condition $5$ is not satisfied, because the length of this string is 8.

Difficulty: MEDIUM

Solutions:
q = int(input())
for i in range(q):
	s = input()
	countC = 0
	countD = 0
	countS = 0
	countL = 0
	n = len(s)
	if n > 9:
		for t in s[0:n]:
			if t.islower() == True:
				countL += 1
				break
		for j in s[1:n - 1]:
			if j.isupper() == True:
				countC += 1
				break
		for k in s[1:n - 1]:
			if k.isdigit() == True:
				countD += 1
				break
		for p in s[1:n - 1]:
			if p == '@' or p == '#' or p == '%' or (p == '&') or (p == '?'):
				countS += 1
				break
		if countC == 1 and countD == 1 and (countS == 1) and (countL == 1):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


from functools import reduce
n = int(input())
for _ in range(n):
	s = list(input())
	f = [False for i in range(4)]
	r = lambda a, b: a and b
	i = 1
	t = {'@', '#', '%', '&', '?'}
	x = len(s) > 9
	f[0] = s[0].islower()
	if not x:
		print('NO')
		continue
	while not reduce(r, f) and i < len(s) - 1:
		f[0] = f[0] or s[i].islower()
		f[1] = f[1] or s[i].isupper()
		f[2] = f[2] or s[i].isdigit()
		f[3] = f[3] or s[i] in t
		i += 1
	f[0] = f[0] or s[i].islower()
	if reduce(r, f):
		print('YES')
	else:
		print('NO')


t = int(input())

def check(s):
	if len(s) < 10:
		return False
	else:
		l = len(s)
		sa = 0
		la = 0
		n = 0
		sc = 0
		for i in range(l):
			if s[i] in 'abcdefghijklmnopqrstuvwxyz':
				sa += 1
			if s[i] in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' and (i != 0 and i != l - 1):
				la += 1
			if s[i] in '@#%&?' and (i != 0 and i != l - 1):
				sc += 1
			if s[i] in '0123456789' and (i != 0 and i != l - 1):
				n += 1
		if sa >= 1 and la >= 1 and (n >= 1) and (sc >= 1):
			return True
		else:
			return False
for i in range(t):
	s = input()
	print('YES' if check(s) else 'NO')


def contieneMayusculas(cadena):
	if 'A' in cadena:
		return True
	if 'B' in cadena:
		return True
	if 'C' in cadena:
		return True
	if 'D' in cadena:
		return True
	if 'E' in cadena:
		return True
	if 'F' in cadena:
		return True
	if 'G' in cadena:
		return True
	if 'H' in cadena:
		return True
	if 'I' in cadena:
		return True
	if 'J' in cadena:
		return True
	if 'K' in cadena:
		return True
	if 'L' in cadena:
		return True
	if 'M' in cadena:
		return True
	if 'N' in cadena:
		return True
	if 'O' in cadena:
		return True
	if 'P' in cadena:
		return True
	if 'Q' in cadena:
		return True
	if 'R' in cadena:
		return True
	if 'S' in cadena:
		return True
	if 'T' in cadena:
		return True
	if 'U' in cadena:
		return True
	if 'V' in cadena:
		return True
	if 'W' in cadena:
		return True
	if 'X' in cadena:
		return True
	if 'Y' in cadena:
		return True
	if 'Z' in cadena:
		return True
	else:
		return False

def contieneMinuscula(cadena):
	if 'a' in cadena:
		return True
	if 'b' in cadena:
		return True
	if 'c' in cadena:
		return True
	if 'd' in cadena:
		return True
	if 'e' in cadena:
		return True
	if 'f' in cadena:
		return True
	if 'g' in cadena:
		return True
	if 'h' in cadena:
		return True
	if 'i' in cadena:
		return True
	if 'j' in cadena:
		return True
	if 'k' in cadena:
		return True
	if 'l' in cadena:
		return True
	if 'm' in cadena:
		return True
	if 'n' in cadena:
		return True
	if 'o' in cadena:
		return True
	if 'p' in cadena:
		return True
	if 'q' in cadena:
		return True
	if 'r' in cadena:
		return True
	if 's' in cadena:
		return True
	if 't' in cadena:
		return True
	if 'u' in cadena:
		return True
	if 'v' in cadena:
		return True
	if 'w' in cadena:
		return True
	if 'x' in cadena:
		return True
	if 'y' in cadena:
		return True
	if 'z' in cadena:
		return True
	else:
		return False

def contieneNumero(cadena):
	if '0' in cadena:
		return True
	if '1' in cadena:
		return True
	if '2' in cadena:
		return True
	if '3' in cadena:
		return True
	if '4' in cadena:
		return True
	if '5' in cadena:
		return True
	if '6' in cadena:
		return True
	if '7' in cadena:
		return True
	if '8' in cadena:
		return True
	if '9' in cadena:
		return True
	else:
		return False

def contieneEspecial(cadena):
	if '@' in cadena:
		return True
	if '#' in cadena:
		return True
	if '%' in cadena:
		return True
	if '&' in cadena:
		return True
	if '?' in cadena:
		return True
	else:
		return False
import re
T = int(input())
for _ in range(T):
	s = input()
	if len(s) < 10:
		print('NO')
		continue
	elif not contieneMayusculas(s[1:-1]):
		print('NO')
		continue
	elif not contieneEspecial(s[1:-1]):
		print('NO')
		continue
	elif not contieneNumero(s[1:-1]):
		print('NO')
		continue
	elif not contieneMinuscula(s):
		print('NO')
		continue
	print('YES')


def contieneMayusculas(cadena):
	if 'A' in cadena:
		return True
	if 'B' in cadena:
		return True
	if 'C' in cadena:
		return True
	if 'D' in cadena:
		return True
	if 'E' in cadena:
		return True
	if 'F' in cadena:
		return True
	if 'G' in cadena:
		return True
	if 'H' in cadena:
		return True
	if 'I' in cadena:
		return True
	if 'J' in cadena:
		return True
	if 'K' in cadena:
		return True
	if 'L' in cadena:
		return True
	if 'M' in cadena:
		return True
	if 'N' in cadena:
		return True
	if 'O' in cadena:
		return True
	if 'P' in cadena:
		return True
	if 'Q' in cadena:
		return True
	if 'R' in cadena:
		return True
	if 'S' in cadena:
		return True
	if 'T' in cadena:
		return True
	if 'U' in cadena:
		return True
	if 'V' in cadena:
		return True
	if 'W' in cadena:
		return True
	if 'X' in cadena:
		return True
	if 'Y' in cadena:
		return True
	if 'Z' in cadena:
		return True
	else:
		return False

def contieneNumero(cadena):
	if '0' in cadena:
		return True
	if '1' in cadena:
		return True
	if '2' in cadena:
		return True
	if '3' in cadena:
		return True
	if '4' in cadena:
		return True
	if '5' in cadena:
		return True
	if '6' in cadena:
		return True
	if '7' in cadena:
		return True
	if '8' in cadena:
		return True
	if '9' in cadena:
		return True
	else:
		return False

def contieneEspecial(cadena):
	if '@' in cadena:
		return True
	if '#' in cadena:
		return True
	if '%' in cadena:
		return True
	if '&' in cadena:
		return True
	if '?' in cadena:
		return True
	else:
		return False
import re
T = int(input())
for _ in range(T):
	s = input()
	if len(s) < 10:
		print('NO')
		continue
	elif not re.search('[A-Z]', s[1:-1]):
		print('NO')
		continue
	elif not re.search('[0-9]', s[1:-1]):
		print('NO')
		continue
	elif not re.search("['@', '#', '%', '&', '?']", s[1:-1]):
		print('NO')
		continue
	elif not re.search('[a-z]', s):
		print('NO')
		continue
	print('YES')


for _ in range(int(input())):
	s = input().strip()
	(dig, sml, cap, cha) = (0, 0, 0, 0)
	chs = ['@', '#', '%', '&', '?']
	nums = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	if len(s) < 10:
		print('NO')
	else:
		for i in range(len(s)):
			if s[i].islower():
				sml = 1
			elif s[i].isupper() and (i != 0 and i != len(s) - 1):
				cap = 1
			elif s[i].isdigit() and (i != 0 and i != len(s) - 1):
				dig = 1
			elif s[i] in chs and (i != 0 and i != len(s) - 1):
				cha = 1
		if dig and sml and cap and cha:
			print('YES')
		else:
			print('NO')


for _ in range(int(input())):
	s = input()
	if len(s) < 10:
		print('NO')
	else:
		(small, caps, digit, spec) = (0, 0, 0, 0)
		sett = ['@', '#', '%', '&', '?']
		nums = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
		for i in range(len(s)):
			if s[i] >= 'a' and s[i] <= 'z':
				small = 1
			elif s[i] >= 'A' and s[i] <= 'Z' and (i != 0 and i != len(s) - 1):
				caps = 1
			elif s[i] in sett and (i != 0 and i != len(s) - 1):
				spec = 1
			elif s[i] in nums and (i != 0 and i != len(s) - 1):
				digit = 1
		if small and caps and spec and digit:
			print('YES')
		else:
			print('NO')


a = ['@', '#', '%', '&', '?']
for i in range(int(input())):
	s = input()
	l = [0]
	l.append(len(s) - 1)
	b = 0
	c = 0
	d = 0
	e = 0
	for i in range(len(s)):
		if i not in l and s[i].isupper() == True:
			b += 1
		elif s[i].islower() == True:
			c += 1
		elif i not in l and s[i] in a:
			d += 1
		elif i not in l and s[i].isdigit() == True:
			e += 1
	if len(s) >= 10 and b >= 1 and (c >= 1) and (d >= 1) and (e >= 1):
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	n = len(s)
	if n < 10:
		print('NO')
	else:
		(u, d, sp, l) = (False, False, False, False)
		for i in range(n):
			if s[i] >= 'a' and s[i] <= 'z':
				l = True
			if i > 0 and i < n - 1:
				if s[i].isupper():
					u = True
				elif s[i].isdigit():
					d = True
				elif s[i] in {'@', '#', '%', '&', '?'}:
					sp = True
		if u and d and sp and l:
			print('YES')
		else:
			print('NO')


for i in range(int(input())):
	(Low, Up, Num, Spc) = (0, 0, 0, 0)
	S = input()
	if len(S) >= 10:
		for i in range(len(S)):
			if S[i] >= 'a' and S[i] <= 'z':
				Low = 1
			if i > 0 and i < len(S) - 1:
				if S[i] >= 'A' and S[i] <= 'Z':
					Up = 1
				if S[i] >= '0' and S[i] <= '9':
					Num = 1
				if S[i] == '@' or S[i] == '%' or S[i] == '#' or (S[i] == '&') or (S[i] == '?'):
					Spc = 1
	if Low and Up and Num and Spc:
		print('YES')
	else:
		print('NO')


import re
t = int(input())
for i in range(t):
	password = input()
	lower = re.search('[a-z]', password)
	upper = re.search('[A-Z]', password[1:-1])
	digit = re.search('[0-9]', password[1:-1])
	special = re.search('[@#$%&?]', password[1:-1])
	if len(password) >= 10 and lower and upper and digit and special:
		print('YES')
	else:
		print('NO')


lowerCase = 'abcdefghijklmnopqrstuvwxyz'
upperCase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
digitCase = '0123456789'
specialCase = '@#%&?'
T = int(input())
for i in range(T):
	lower = 0
	upper = 0
	digit = 0
	special = 0
	password = input()
	if len(password) < 10:
		print('NO')
	else:
		for i in range(len(password)):
			if password[i] in lowerCase:
				lower = 1
			elif i > 0 and i < len(password) - 1:
				if password[i] in upperCase:
					upper = 1
				elif password[i] in digitCase:
					digit = 1
				elif password[i] in specialCase:
					special = 1
		if lower and upper and digit and special:
			print('YES')
		else:
			print('NO')


t = int(input())
for _ in range(t):
	s = input()
	k = len(s)
	m = ''
	if len(s) > 9:
		for i in s:
			if i.islower() == True:
				m = m + 'a'
				break
		for j in range(1, k - 1):
			if s[j].isupper() == True:
				m = m + 'b'
			elif s[j].isdigit() == True:
				m = m + 'c'
			elif s[j] in ['@', '#', '%', '&', '?']:
				m = m + 'd'
		a = set(m)
		l = ''
		for x in a:
			l = l + x
		z = sorted(l)
		y = ''.join(z)
		if y == 'abcd':
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


T = int(input())
while T > 0:
	S = str(input())
	l = u = n = sp = 0
	if len(S) >= 10:
		for i in S:
			alpha = 'abcdefghijklmnopqrstuvwxyz'
			num = '0123456789'
			spl = '@#%&?'
			if i in alpha:
				l = l + 1
			elif i in alpha.upper() and 1 <= S.index(i) <= len(S) - 2:
				u = u + 1
			elif i in num and 1 <= S.index(i) <= len(S) - 2:
				n = n + 1
			elif i in spl and 1 <= S.index(i) <= len(S) - 2:
				sp = sp + 1
		if l >= 1 and u >= 1 and (n >= 1) and (sp >= 1):
			print('YES')
		else:
			print('NO')
	else:
		print('NO')
	T = T - 1


import sys
input = sys.stdin.readline
r = 'QWERTYUIOPASDFGHJKLZXCVBNM'
A = set(list(r))
a = set(list(r.lower()))
n = set(['1', '2', '3', '4', '5', '6', '7', '8', '9', '0'])
c = set(['@', '#', '%', '&', '?'])
for i in range(int(input().strip())):
	s = list(input().strip())
	if len(s) < 10:
		print('NO')
		continue
	aa = False
	AA = False
	CC = False
	NN = False
	if s[0] in a or s[-1] in a:
		aa = True
	for x in range(1, len(s) - 1):
		if s[x] in A:
			AA = True
		elif s[x] in n:
			NN = True
		elif s[x] in c:
			CC = True
		elif s[x] in a:
			aa = True
	if not AA or not CC or (not NN) or (not aa):
		print('NO')
		continue
	print('YES')


for _ in range(int(input())):
	i = input()
	ans = False
	alpha = 'abcdefghijklmnopqrstuvwxyz'
	num = '0123456789'
	spl = '@#%&?'
	for val in alpha:
		if val in i:
			ans = True
			break
	temp = False
	temp2 = False
	if len(i) < 10:
		ans = False
	i = i[1:-1]
	for val in alpha:
		if val.upper() in i:
			temp2 = True
			break
	if not temp2:
		ans = False
	for val in range(10):
		if str(val) in i:
			temp = True
			break
	if not temp:
		ans = False
	if '@' not in i and '#' not in i and ('%' not in i) and ('&' not in i) and ('?' not in i):
		ans = False
	if ans:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	password = list(input())
	a = 0
	b = 0
	c = 0
	d = 0
	if len(password) > 9:
		for i in range(1, len(password) - 1):
			if password[i] == '@' or password[i] == '#' or password[i] == '%' or (password[i] == '&') or (password[i] == '?'):
				a = 1
			if 64 < ord(password[i]) < 91:
				b = 1
			if password[i].isdigit() == True:
				c = 1
		for i in range(0, len(password)):
			if 96 < ord(password[i]) < 123:
				d = 1
	if a == b == c == d == 1:
		print('YES')
	else:
		print('NO')


import re
for _ in range(int(input())):
	s = input()
	lower = re.search('[a-z]', s)
	upper = re.search('[A-Z]', s[1:-1])
	num = list('0123456789')
	number = None
	special = ['@', '#', '%', '&', '?']
	special_char = None
	for i in num:
		if i in s[1:-1]:
			number = True
			break
	for i in special:
		if i in s[1:-1]:
			special_char = True
			break
	if len(s) < 10:
		print('NO')
	elif lower == None:
		print('NO')
	elif upper == None:
		print('NO')
	elif number == None:
		print('NO')
	elif special_char == None:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	P = input()
	try:
		s = '[@_!#$%^&*()<>?/\\|}{~:]'
		s1 = s2 = s3 = s4 = s5 = False
		flag = 0
		for i in range(len(P)):
			if P[i].islower():
				s1 = True
			if i > 0 and i < len(P) - 1 and P[i].isupper():
				s2 = True
			if i > 0 and i < len(P) - 1 and P[i].isdigit():
				s3 = True
			if i > 0 and i < len(P) - 1 and (P[i] in s):
				s4 = True
			if len(P) >= 10:
				s5 = True
			if s1 and s2 and s3 and s4 and s5:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')
	except:
		pass


import numpy as np
T = int(input())
sp = '@#%&?'
for i in range(T):
	s = input()
	a = 0
	b = 0
	c = 0
	d = 0
	e = 0
	f = 0
	if len(s) < 10:
		a += 1
	for i in range(1, len(s) - 1):
		if s[i] in sp:
			b += 1
		if s[i].isupper():
			c += 1
		if s[i].islower():
			d += 1
		if s[i].isdigit():
			e += 1
	if d == 0:
		if s[0].islower() or s[-1].islower():
			d += 1
	if a == 0 and b != 0 and (c != 0) and (d != 0) and (e != 0):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	a = input()
	(b, c, d, e) = (0, 0, 0, 0)
	for i in range(len(a)):
		if a[i].islower():
			b += 1
		elif i > 0 and i < len(a) - 1 and a[i].isupper():
			c += 1
		elif i > 0 and i < len(a) - 1 and a[i].isdigit():
			d += 1
		elif i > 0 and i < len(a) - 1 and (a[i] in '@,&,#,%,?'):
			e += 1
	if len(a) >= 10 and b >= 1 and (c >= 1) and (d >= 1) and (e >= 1):
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	pa = str(input())
	s = 0
	c = 0
	no = 0
	sp = 0
	o = 0
	l = len(pa)
	if l >= 10:
		for j in pa:
			if 97 <= ord(j) <= 122:
				s = 1
			elif 65 <= ord(j) <= 90 and o != 0 and (o != l - 1):
				c = 1
			elif j.isdigit() and o != 0 and (o != l - 1):
				no = 1
			elif (j == '@' or j == '#' or j == '%' or (j == '&') or (j == '?')) and o != 0 and (o != l - 1):
				sp = 1
			o += 1
		if s == 0 or c == 0 or no == 0 or (sp == 0):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	fl1 = fl2 = fl3 = fl4 = 0
	if len(s) > 9:
		for j in range(1, len(s) - 1):
			if s[j] in '@#%?&':
				fl1 = 1
			if 64 < ord(s[j]) < 91:
				fl2 = 1
			if s[j].isdigit():
				fl3 = 1
		for k in range(len(s)):
			if 96 < ord(s[k]) < 123:
				fl4 = 1
	if fl1 and fl2 and fl3 and fl4:
		print('YES')
	else:
		print('NO')


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def outp(n):
	sys.stdout.write(str(n) + '\n')

def outlt(lst):
	sys.stdout.write(' '.join(map(str, lst)) + '\n')

def outplt(lst):
	sys.stdout.write('\n'.join(map(str, lst)))

def outpltlt(lst):
	sys.stdout.write('\n'.join(map(str, (' '.join(map(str, a)) for a in lst))))
special = set([x for x in '@#%&?'])
ans = []
for _ in range(inp()):
	S = insr()
	(l, u, d, s) = [False] * 4
	an = 'NO'
	if len(S) >= 10:
		if S[0].islower() or S[-1].islower():
			l = True
		for ch in S[1:-1]:
			if not l and ch.islower():
				l = True
			if not u and ch.isupper():
				u = True
			if not d and ch.isdigit():
				d = True
			if not s and ch in special:
				s = True
		if l and u and d and s:
			an = 'YES'
	ans.append(an)
outplt(ans)


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	return input().strip()

def invr():
	return map(int, input().split())

def outp(n):
	sys.stdout.write(str(n) + '\n')

def outlt(lst):
	sys.stdout.write(' '.join(map(str, lst)) + '\n')

def outplt(lst):
	sys.stdout.write('\n'.join(map(str, lst)))

def outpltlt(lst):
	sys.stdout.write('\n'.join(map(str, (' '.join(map(str, a)) for a in lst))))
lower = set([chr(x) for x in range(ord('a'), ord('z') + 1)])
upper = set([chr(x) for x in range(ord('A'), ord('Z') + 1)])
digits = set([x for x in '0123456789'])
special = set([x for x in '@#%&?'])
ans = []
for _ in range(inp()):
	S = insr()
	ln = len(S)
	(l, u, d, s) = [False] * 4
	if ln < 10:
		an = 'NO'
	else:
		an = 'YES'
		for (i, ch) in enumerate(S):
			if not l and ch in lower:
				l = True
			if i > 0 and i < ln - 1:
				if not u and ch in upper:
					u = True
				if not d and ch in digits:
					d = True
				if not s and ch in special:
					s = True
			if l and u and d and s:
				break
		else:
			an = 'NO'
	ans.append(an)
outplt(ans)


T = int(input())
while T > 0:
	str1 = input()
	l1 = ['q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm']
	l2 = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	l3 = ['@', '#', '%', '&', '?']
	l4 = ['Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M']
	(l1case, l2case, l3case, l4case) = (False, False, False, False)
	if len(str1) < 10:
		print('NO')
	else:
		for i in range(len(str1)):
			if str1[i] in l1:
				l1case = True
			elif str1[i] in l2 and 0 < i < len(str1) - 1:
				l2case = True
			elif str1[i] in l3 and 0 < i < len(str1) - 1:
				l3case = True
			elif str1[i] in l4 and 0 < i < len(str1) - 1:
				l4case = True
		if l1case == True and l2case == True and (l3case == True) and (l4case == True):
			print('YES')
		else:
			print('NO')
	T -= 1


c = 'qwertyuiopasdfghjklzxcvbnm'
dig = '0192837465'

def sol(s):
	if len(s) < 10:
		return False
	for ch in s:
		if ch in c:
			break
	else:
		return False
	for ch in s[1:-1]:
		if ch in c.upper():
			break
	else:
		return False
	for ch in s[1:-1]:
		if ch in dig:
			break
	else:
		return False
	for ch in s[1:-1]:
		if ch in {'@', '#', '%', '&', '?'}:
			break
	else:
		return False
	return True
for _ in range(int(input())):
	s = input()
	if sol(s):
		print('YES')
	else:
		print('NO')


import string

def solve(s):
	big = list(string.ascii_uppercase)
	small = list(string.ascii_lowercase)
	num = ['0', '1', '2', '3', '4', '5', '6', '7', '8', '9']
	char = ['@', '#', '%', '&', '?']
	bigB = False
	smallB = False
	numB = False
	charB = False
	if len(s) < 10:
		return 'NO'
	for i in range(len(s)):
		if s[i] in big:
			if i != 0 and i != len(s) - 1:
				bigB = True
		elif s[i] in small:
			smallB = True
		elif s[i] in char:
			if i != 0 and i != len(s) - 1:
				charB = True
		elif s[i] in num:
			if i != 0 and i != len(s) - 1:
				numB = True
	if bigB and smallB and charB and numB:
		return 'YES'
	else:
		return 'NO'
for _ in range(int(input())):
	s = input()
	print(solve(s))


def Solve(s, n):
	(lower, upper, digit, special) = (0, 0, 0, 0)
	for i in range(n):
		o = ord(s[i])
		if 65 <= o <= 90 and i > 0 and (i < n - 1):
			upper += 1
		elif 97 <= o <= 122:
			lower += 1
		elif 48 <= o <= 57 and i > 0 and (i < n - 1):
			digit += 1
		elif s[i] in ['@', '#', '%', '&', '?'] and i > 0 and (i < n - 1):
			special += 1
	if n >= 10 and special > 0 and (lower > 0) and (upper > 0) and (digit > 0):
		return 'YES'
	return 'NO'
for _ in range(int(input())):
	s = input()
	n = len(s)
	print(Solve(s, n))


try:
	for _ in range(int(input())):
		s = input()
		special = {'@', '#', '%', '&', '?'}
		c1 = c2 = c3 = c4 = c5 = False
		flag = 0
		for i in range(len(s)):
			if s[i].islower():
				c1 = True
			if i > 0 and i < len(s) - 1 and s[i].isupper():
				c2 = True
			if i > 0 and i < len(s) - 1 and s[i].isdigit():
				c3 = True
			if i > 0 and i < len(s) - 1 and (s[i] in special):
				c4 = True
			if len(s) >= 10:
				c5 = True
			if c1 and c2 and c3 and c4 and c5:
				print('YES')
				flag = 1
				break
		if flag == 0:
			print('NO')
except:
	pass


for _ in range(int(input())):
	s = input()
	flag1 = flag2 = flag3 = flag4 = 0
	if len(s) > 9:
		for i in range(1, len(s) - 1):
			if s[i] in '@#%&?':
				flag1 = 1
			if 64 < ord(s[i]) < 91:
				flag2 = 1
			if s[i].isdigit():
				flag3 = 1
		for i in range(len(s)):
			if 96 < ord(s[i]) < 123:
				flag4 = 1
	if flag1 and flag2 and flag3 and flag4:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	string = input()
	low = False
	up = False
	numb = False
	special_char = False
	if 97 <= ord(string[0]) <= 122 or 97 <= ord(string[-1]) <= 122:
		low = True
	for j in string[1:-1]:
		num = ord(j)
		if 97 <= num <= 122:
			low = True
		elif 65 <= num <= 90:
			up = True
		elif 48 <= num <= 57:
			numb = True
		elif j in ['@', '#', '%', '&', '?']:
			special_char = True
	if low and up and numb and special_char and (len(string) >= 10):
		print('YES')
	else:
		print('NO')


N = int(input())
for i in range(N):
	l = input()
	condition1 = False
	condition2 = False
	condition3 = False
	condition4 = False
	condition5 = False
	if len(l) >= 10:
		condition5 = True
	for i in range(len(l)):
		if l[i].islower():
			condition1 = True
		if i != 0 and i != len(l) - 1:
			if l[i].isupper():
				condition2 = True
			if l[i].isdigit():
				condition3 = True
			if l[i] == '@' or l[i] == '#' or l[i] == '%' or (l[i] == '&') or (l[i] == '?'):
				condition4 = True
	if condition1 == condition2 == condition3 == condition4 == condition5 == True:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	st = input()
	if len(st) < 10:
		print('NO')
		continue
	p = 0
	q = 0
	r = 0
	s = 0
	for i in range(1, len(st) - 1):
		if st[i] >= 'a' and st[i] <= 'z':
			p = 1
		elif st[i] >= 'A' and st[i] <= 'Z':
			q = 1
		elif st[i] >= '0' and st[i] <= '9':
			r = 1
		else:
			s = 1
	if st[0] >= 'a' and st[0] <= 'z' or (st[len(st) - 1] >= 'a' and st[len(st) - 1] <= 'z'):
		p = 1
	if p == q == r == s == 1:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	one = 0
	two = 0
	three = 0
	four = 0
	if len(s) >= 10:
		for i in range(len(s)):
			if s[i].islower():
				one += 1
			if i != 0 and i != len(s) - 1:
				if s[i].isupper():
					two += 1
				elif s[i].isdigit():
					three += 1
				elif s[i] in ['@', '#', '%', '&', '?']:
					four += 1
		if one == 0 or two == 0 or three == 0 or (four == 0):
			print('NO')
		else:
			print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	lc = 'qwertyuiopasdfghjklzxcvbnm'
	uc = 'QWERTYUIOPASDFGHJKLZXCVBNM'
	num = '01233456789'
	sc = '@#%&?'
	l = [0, 0, 0, 0]
	st = input()
	flag = 0
	if len(st) >= 10:
		for x in range(0, len(st)):
			if min(l) != 0:
				flag = 1
				break
			if st[x] in lc:
				l[0] += 1
			if x > 0 and x < len(st) - 1:
				if st[x] in uc:
					l[1] += 1
				elif st[x] in num:
					l[2] += 1
				elif st[x] in sc:
					l[3] += 1
		if flag == 1:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
while t:
	s = input()
	accept1 = False
	accept2 = False
	accept3 = False
	accept4 = False
	accept5 = False
	if len(s) >= 10:
		accept5 = True
	for i in range(1, len(s) - 1):
		if s[i].isnumeric():
			accept3 = True
		if s[i].isupper():
			accept2 = True
		if s[i] == '@' or s[i] == '#' or s[i] == '%' or (s[i] == '&') or (s[i] == '?'):
			accept4 = True
	for i in s:
		if i.islower():
			accept1 = True
	if accept1 and accept2 and accept3 and accept4 and accept5:
		print('YES')
	else:
		print('NO')
	t -= 1


T = int(input())
for i in range(T):
	S = input()
	letter = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	Pass = '0123456789'
	special = '@#%&?'
	(item, upper, num, special) = (0, 0, 0, 0)
	if len(S) >= 10:
		for i in S:
			if i in letter.lower():
				item = 1
		for i in range(1, len(S) - 1):
			if S[i] in letter:
				upper = 1
		for i in range(1, len(S) - 1):
			if S[i].isdigit():
				num = 1
		for i in range(1, len(S) - 1):
			if S[i] == '@' or S[i] == '#' or S[i] == '%' or (S[i] == '&') or (S[i] == '?'):
				special = 1
	if item == 1 and upper == 1 and (num == 1) and (special == 1):
		print('YES')
	else:
		print('NO')


tests = int(input())
for i in range(tests):
	string = input()
	lower_case = False
	upper_case = False
	digits = False
	special_char = False
	if 97 <= ord(string[0]) <= 122 or 97 <= ord(string[-1]) <= 122:
		lower_case = True
	for j in string[1:-1]:
		num = ord(j)
		if 97 <= num <= 122:
			lower_case = True
		elif 65 <= num <= 90:
			upper_case = True
		elif 48 <= num <= 57:
			digits = True
		elif j in ['@', '#', '%', '&', '?']:
			special_char = True
	if lower_case and upper_case and digits and special_char and (len(string) >= 10):
		print('YES')
	else:
		print('NO')


z = int(input())
for i in range(z):
	x = list(input())
	flag1 = 0
	flag2 = 0
	flag3 = 0
	flag4 = 0
	if len(x) > 9:
		for i in range(1, len(x) - 1):
			if x[i] == '@' or x[i] == '#' or x[i] == '%' or (x[i] == '&') or (x[i] == '?'):
				flag1 = 1
			if 64 < ord(x[i]) < 91:
				flag2 = 1
			if x[i].isdigit() == True:
				flag3 = 1
		for i in range(0, len(x)):
			if 96 < ord(x[i]) < 123:
				flag4 = 1
	if flag1 == flag2 == flag3 == flag4 == 1:
		print('YES')
	else:
		print('NO')


alphabet = 'abcdefghijklmnopqrstuvwxyz'
Capitals = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
numbers = '1234567890'
special = '@#%&?'
for i in range(int(input())):
	s = input()
	check1 = check2 = check3 = check4 = check5 = False
	if len(s) >= 10:
		check5 = True
	for i in s:
		if i in alphabet:
			check1 = True
			break
	for i in s[1:-1]:
		if i in Capitals:
			check2 = True
			break
	for i in s[1:-1]:
		if i in numbers:
			check3 = True
			break
	for i in s[1:-1]:
		if i in special:
			check4 = True
			break
	if check4 and check3 and check2 and check1 and check5:
		print('YES')
	else:
		print('NO')


alphabet = 'abcdefghijklmnopqrstuvwxyz'
alphabetb = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
numbers = '1234567890'
special = '@#%&?'
for _ in range(int(input())):
	password = input()
	case1 = case2 = case3 = case4 = 0
	case5 = len(password) >= 10
	for a in alphabet:
		if a in password:
			case1 = 1
			break
	password = password[1:-1]
	for ab in alphabetb:
		if ab in password:
			case2 = 1
			break
	for n in numbers:
		if n in password:
			case3 = 1
			break
	for s in special:
		if s in password:
			case4 = 1
			break
	if case1 and case2 and case3 and case4 and case5:
		print('YES')
	else:
		print('NO')


special_symbols = {'@', '#', '%', '&', '?'}

def check_security(pwd):
	flags = [False, False, False, False]
	l = len(pwd)
	for i in range(l):
		if pwd[i].islower():
			flags[0] = True
		if i != 0 and i != l - 1:
			if pwd[i].isupper():
				flags[1] = True
			if pwd[i].isdigit():
				flags[2] = True
			if pwd[i] in special_symbols:
				flags[3] = True
	return flags
for _ in range(int(input())):
	pwd = input()
	if len(pwd) >= 10:
		flags = check_security(pwd)
		if flags[0] and flags[1] and flags[2] and flags[3]:
			print('YES')
		else:
			print('NO')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	(lower_check, upper_check, digit_check, spec_check) = (0, 0, 0, 0)
	if len(s) < 10:
		print('NO')
		continue
	if lower_check == 0:
		if s[0].islower() or s[-1].islower():
			lower_check = 1
	for j in range(1, len(s) - 1):
		i = s[j]
		if lower_check == 0:
			if i.islower():
				lower_check = 1
		if upper_check == 0:
			if i.isupper():
				upper_check = 1
		if digit_check == 0:
			if i.isdigit():
				digit_check = 1
		if spec_check == 0:
			if i in '@#%&?':
				spec_check = 1
	if lower_check + upper_check + digit_check + spec_check == 4:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	s = input()
	check = 0
	(lower_check, upper_check, digit_check, spec_check) = (0, 0, 0, 0)
	if len(s) > 9:
		if lower_check == 0:
			if s[0].islower() or s[-1].islower():
				lower_check = 1
				check += 1
		for j in range(1, len(s) - 1):
			i = s[j]
			if lower_check == 0:
				if i.islower():
					lower_check = 1
					check += 1
			if upper_check == 0:
				if i.isupper():
					upper_check = 1
					check += 1
			if digit_check == 0:
				if i.isdigit():
					digit_check = 1
					check += 1
			if spec_check == 0:
				if i in '@#%&?':
					spec_check = 1
					check += 1
			if check == 4:
				print('YES')
				break
	if check != 4:
		print('NO')


for _ in range(int(input())):
	s = input()
	cnt = 0
	check = 0
	sp_char = ['@', '#', '%', '&', '?']
	(lower_check, upper_check, digit_check, spec_check) = (0, 0, 0, 0)
	if len(s) < 10:
		print('NO')
		continue
	if lower_check == 0:
		if s[0].islower() or s[-1].islower():
			lower_check = 1
			check += 1
	while cnt < len(s) - 2 and check != 4:
		cnt += 1
		i = s[cnt]
		if lower_check == 0:
			if i.islower():
				lower_check = 1
				check += 1
		if upper_check == 0:
			if i.isupper():
				upper_check = 1
				check += 1
		if digit_check == 0:
			if i.isdigit():
				digit_check = 1
				check += 1
		if spec_check == 0:
			if i in sp_char:
				spec_check = 1
				check += 1
	if check == 4:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	s = input()
	flag = None
	inside = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789@#%&?'
	if len(s) >= 10:
		if 'a' in s or 'b' in s or 'c' in s or ('d' in s) or ('e' in s) or ('f' in s) or ('g' in s) or ('h' in s) or ('i' in s) or ('j' in s) or ('k' in s) or ('l' in s) or ('m' in s) or ('n' in s) or ('o' in s) or ('p' in s) or ('q' in s) or ('r' in s) or ('s' in s) or ('t' in s) or ('u' in s) or ('v' in s) or ('w' in s) or ('x' in s) or ('y' in s) or ('z' in s):
			s = s[1:-1]
			if '@' in s or '#' in s or '%' in s or ('&' in s) or ('?' in s):
				if '0' in s or '1' in s or '2' in s or ('3' in s) or ('4' in s) or ('5' in s) or ('6' in s) or ('7' in s) or ('8' in s) or ('9' in s):
					if 'A' in s or 'B' in s or 'C' in s or ('D' in s) or ('E' in s) or ('F' in s) or ('G' in s) or ('H' in s) or ('I' in s) or ('J' in s) or ('K' in s) or ('L' in s) or ('M' in s) or ('N' in s) or ('O' in s) or ('P' in s) or ('Q' in s) or ('R' in s) or ('S' in s) or ('T' in s) or ('U' in s) or ('V' in s) or ('W' in s) or ('X' in s) or ('Y' in s) or ('Z' in s):
						print('YES')
					else:
						print('NO')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	a = input()
	if len(a) >= 10:
		ansa = [a[i] for i in range(len(a)) if a[i].islower()]
		if len(ansa) >= 1:
			ansb = [a[i] for i in range(1, len(a) - 1) if a[i].isupper()]
			if len(ansb) >= 1:
				if len([a[i] for i in range(1, len(a) - 1) if a[i].isdigit()]) >= 1:
					if len([a[i] for i in range(1, len(a) - 1) if a[i] in ['@', '#', '%', '&', '?']]) >= 1:
						print('YES')
					else:
						print('NO')
				else:
					print('NO')
			else:
				print('NO')
		else:
			print('NO')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = input()
	s = ''
	for j in n:
		if ord(j) <= 122 and ord(j) >= 97:
			s = s + '1'
			break
	for j in range(1, len(n) - 1):
		if ord(n[j]) <= 90 and ord(n[j]) >= 65:
			s = s + '1'
			break
	for j in range(1, len(n) - 1):
		if ord(n[j]) == 64 or ord(n[j]) == 35 or ord(n[j]) == 37 or (ord(n[j]) == 38) or (ord(n[j]) == 63):
			s = s + '1'
			break
	for j in range(1, len(n) - 1):
		if ord(n[j]) <= 58 and ord(n[j]) >= 48:
			s = s + '1'
			break
	if len(n) >= 10:
		s = s + '1'
	if s == '11111':
		print('YES')
	else:
		print('NO')


T = int(input())
while T != 0:
	password = input()
	if len(password) >= 10:
		speclCon = False
		upperCon = False
		lowerCon = False
		digitCon = False
		insidePass = password[1:len(password) - 1]
		for i in insidePass:
			if i in 'abcdefghijklmnopqrstuvwxyz':
				lowerCon = True
			if i in 'ABCDEFGHIJKLMNOPQRSTUVWXYZ':
				upperCon = True
			if i in '0123456789':
				digitCon = True
			if i in '@#%&?':
				speclCon = True
			if speclCon and digitCon and lowerCon and upperCon:
				print('YES')
				break
		else:
			lowerCon = password[0] in 'abcdefghijklmnopqrstuvwxyz' or password[-1] in 'abcdefghijklmnopqrstuvwxyz'
			if speclCon and digitCon and lowerCon and upperCon:
				print('YES')
			else:
				print('NO')
	else:
		print('NO')
	T -= 1


for i in range(int(input())):
	S1 = input()
	S = S1[1:-1]
	l = ['@', '#', '%', '&', '?']
	N = [number for number in range(10)]
	A = [chr(item) for item in range(65, 91)]
	a = [chr(items) for items in range(97, 123)]
	counts = 0
	for x in range(len(l)):
		counts += S.count(l[x])
	countA = 0
	for alphaA in range(len(A)):
		countA += S.count(A[alphaA])
	counta = 0
	for alpha in range(len(a)):
		counta += S1.count(a[alpha])
	countn = 0
	for num in range(len(N)):
		countn += S.count(str(N[num]))
	if counta * counts * countA * countn > 1 and len(S1) >= 10:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	S1 = input()
	S2 = S1[1:-1]
	c1 = 0
	c2 = 0
	c3 = 0
	c4 = 0
	spl = ['@', '#', '%', '&', '?']
	for item in S1:
		if item.islower():
			c4 += 1
	for item in S2:
		if item.isupper():
			c1 += 1
		if item.isdigit():
			c2 += 1
		if item in spl:
			c3 += 1
	if c1 * c2 * c3 * c4 > 1 and len(S1) >= 10:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	s = input()
	(up, low, digit, spec) = (0, 0, 0, 0)
	t = ['@', '#', '%', '&', '?']
	d = [int(x) for x in range(0, 10)]
	if len(s) < 10:
		print('NO')
	else:
		for i in range(len(s)):
			if s[i].islower():
				low += 1
			elif i != 0 and i != len(s) - 1 and s[i].isupper():
				up += 1
			elif i != 0 and i != len(s) - 1 and (s[i] in t):
				spec += 1
			elif i != 0 and i != len(s) - 1 and (int(s[i]) in d):
				digit += 1
			if up > 0 and low > 0 and (digit > 0) and (spec > 0):
				print('YES')
				break
		else:
			print('NO')