ABCXYZ company has up to 100 employees. 

The company decides to create a unique identification number (UID) for each of its employees. 

The company has assigned you the task of validating all the randomly generated UIDs.

A valid UID must follow the rules below:  

It must contain at least $2$ uppercase English alphabet characters.   
It must contain at least $3$ digits ($\mbox{0}$ - $\mbox{9}$).  
It should only contain alphanumeric characters ($\boldsymbol{a}$ - $z$, $\mbox{A}$ - $\mbox{Z}$ & $\mbox{0}$ - $\mbox{9}$).  
No character should repeat.  
There must be exactly $10$ characters in a valid UID.

Input Format

The first line contains an integer $\mathbf{T}$, the number of test cases. 

The next $\mathbf{T}$ lines contains an employee's UID.

Output Format

For each test case, print 'Valid' if the UID is valid. Otherwise, print 'Invalid', on separate lines. Do not print the quotation marks.

Sample Input
2
B1CD102354
B1CDEF2354

Sample Output
Invalid
Valid

Explanation

B1CD102354: $\mbox{1}$ is repeating →  Invalid 

B1CDEF2354: Valid

Difficulty: EASY

Solutions:
import re
n = int(input())
regex_for_valid_uid_ignoring_repeats = re.compile('^(?=(.*?[a-zA-Z]){2})(?=(.*?\\d){3})(?:[a-zA-Z0-9]{10})$')
regex_for_no_repeats = re.compile('^(?:([A-Za-z0-9])(?!.*\\1))+$')
for _ in range(n):
	uid = input()
	if regex_for_valid_uid_ignoring_repeats.match(uid) and regex_for_no_repeats.match(uid):
		print('Valid')
	else:
		print('Invalid')


import string

def valid(s):
	if len(s) != 10:
		return False
	if len(set(s)) < len(s):
		return False
	if not s.isalnum:
		return False
	u = 0
	d = 0
	for c in s:
		if c in string.ascii_uppercase:
			u += 1
		if c in string.digits:
			d += 1
	return u >= 2 and d >= 3
for i in range(int(input())):
	print(('V' if valid(input()) else 'Inv') + 'alid')


import re
n = int(input())
a = list()
k = 0
for i in range(n):
	a.append(input())
for i in range(n):
	if a[i].isalnum() and len(a[i]) == 10:
		if re.search('([A-Z].*){2}', a[i]) and re.search('([0-9].*){3}', a[i]):
			for j in a[i]:
				if a[i].count(j) > 1:
					k = 0
					break
				else:
					k = 1
			if k == 1:
				print('Valid')
			else:
				print('Invalid')
		else:
			print('Invalid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	uid = input().strip()
	if uid.isalnum() and len(uid) == 10 and (sum([x.isnumeric() for x in uid]) > 2) and (sum([x.isupper() for x in uid]) > 1) and (len(set(uid)) == 10):
		print('Valid')
	else:
		print('Invalid')


import re

def valid(s):
	if not re.match('^[0-9a-zA-Z]{10}$', s):
		return False
	if sum([c.isdigit() for c in s]) < 3:
		return False
	if sum([c.isupper() for c in s]) < 2:
		return False
	s = sorted(s)
	for i in range(1, len(s)):
		if s[i - 1] == s[i]:
			return False
	return True
N = int(input())
for _ in range(N):
	if valid(input()):
		print('Valid')
	else:
		print('Invalid')


for _ in range(int(input())):
	uid = input()
	if len(uid) != 10:
		print('Invalid')
	elif len(set(uid)) != 10:
		print('Invalid')
	else:
		num_uppercase = 0
		num_digits = 0
		valid = True
		for c in uid:
			if not c.isalnum():
				valid = False
				break
			elif c.isupper():
				num_uppercase += 1
			elif c.isdigit():
				num_digits += 1
		valid &= num_uppercase >= 2 and num_digits >= 3
		print('Valid' if valid else 'Invalid')


import re
N = int(input())
for i in range(N):
	S = input()
	Match = False
	if not re.search('(?:([A-Za-z0-9])(?=.*\\1))', S):
		if re.search('[A-Z].*[A-Z]', S):
			if re.search('\\d.*\\d.*\\d', S):
				if not re.search('[^A-Za-z0-9]', S):
					if len(S) == 10:
						print('Valid')
						Match = True
	if not Match:
		print('Invalid')


import re
for i in range(int(input())):
	s = input().strip()
	print('Valid' if all([re.match('^[a-zA-Z0-9]{10}$', s), re.match('^.*[A-Z].*[A-Z].*$', s), re.match('^.*[0-9].*[0-9].*[0-9].*$', s), not re.compile('^.*(.).*\\1.*$').match(s)]) else 'Invalid')


import re
for _ in range(int(input())):
	uid = input()
	if re.match('^[A-Za-z0-9]{10}$', uid) and re.match('.*([A-Z].*){2}', uid) and re.match('.*([0-9].*){3}', uid) and (not re.match('.*(.).*\\1', uid)):
		print('Valid')
	else:
		print('Invalid')


from re import match, compile, findall
right_chars = compile('[a-zA-Z0-9]{10}')
upper_chars = compile('([A-Z])')
digit_chars = compile('([0-9])')
len_match = lambda m: 0 if m == None else len(m)
for i in range(int(input())):
	uid = input().strip()
	verification = len(set(uid)) == 10 and bool(match(right_chars, uid)) and (len_match(findall(upper_chars, uid)) >= 2) and (len_match(findall(digit_chars, uid)) >= 3)
	print('Valid' if verification else 'Invalid')


import re
n = int(input())
ret = []
for _ in range(n):
	id = input()
	valid = True
	if re.fullmatch('[a-zA-Z0-9]{10}', id) == None:
		valid = False
	if re.search('[A-Z].*[A-Z]', id) == None:
		valid = False
	if re.search('[0-9].*[0-9].*[0-9]', id) == None:
		valid = False
	if re.search('([a-zA-Z0-9]).*\\1', id):
		valid = False
	if valid:
		print('Valid')
	else:
		print('Invalid')


import re

def is_ten(s):
	return len(s) == 10

def is_two_up(s):
	upper = re.findall('[A-Z]', s)
	return len(upper) >= 2

def is_three_digs(s):
	upper = re.findall('[0-9]', s)
	return len(upper) >= 3

def is_alnum(s):
	return s.isalnum()

def is_uniq(s):
	return len(list(s)) == len(set(list(s)))

def validate(s):
	val = []
	val.append(is_ten(s))
	val.append(is_two_up(s))
	val.append(is_three_digs(s))
	val.append(is_alnum(s))
	val.append(is_uniq(s))
	return val
for _ in range(int(input())):
	validations = validate(input().strip())
	if all(validations):
		print('Valid')
	else:
		print('Invalid')


from collections import Counter
import re

def is_valid(S):
	if any((x > 1 for x in Counter(S).values())):
		return False
	if not re.match('[a-zA-Z0-9]{10}', S):
		return False
	return sum((1 for _ in re.finditer('\\d', S))) >= 3 and sum((1 for _ in re.finditer('\\d', S))) >= 2
for _ in range(int(input())):
	print('Valid' if is_valid(input()) else 'Invalid')


import re
for i in range(int(input())):
	S = input()
	_l0 = re.findall('[A-Z]', S)
	_l1 = re.findall('\\d', S)
	_re = re.match('^[a-zA-Z0-9]{10}$', S)
	_re1 = re.search('([a-zA-Z0-9]).*\\1', S)
	if len(_l0) >= 2 and len(_l1) >= 3 and _re and (not _re1):
		print('Valid')
	else:
		print('Invalid')


for i in range(int(input())):
	uid = input().rstrip()
	if len(uid) == 10 and len(set(uid)) == 10 and (len(set(uid) & set([str(x) for x in range(10)])) >= 3) and (len(list(filter(lambda x: x.isupper(), uid))) >= 2):
		print('Valid')
	else:
		print('Invalid')


import re

def validate(data):
	return 'Valid' if all([len(re.findall('[A-Z]', data)) >= 2, len(re.findall('[0-9]', data)) >= 3, len(re.findall('[^a-zA-Z0-9]', data)) == 0, len(data) == 10, len(re.findall('.*(.).*\\1', data)) == 0]) else 'Invalid'
print(*list(map(validate, [input().strip() for i in range(int(input()))])), sep='\n')


import re
pos_tests = ['^[a-zA-Z0-9]{10}$', '([A-Z].*){2}', '([0-9].*){3}']
neg_test = '(.).*\\1+'
for line in range(int(input().strip())):
	string = input().strip()
	if all([re.search(test, string) for test in pos_tests]) and (not re.search(neg_test, string)):
		print('Valid')
	else:
		print('Invalid')


__author__ = 'sunghyo.jung'
import re
P0 = '^[a-zA-Z0-9]{10}$'
P1 = '[A-Z]'
P2 = '[0-9]'
P3 = '(.).*\\1'
for i in range(int(input().strip())):
	s = input().strip()
	print('Valid' if re.match(P0, s) and len(re.findall(P1, s)) >= 2 and (len(re.findall(P2, s)) >= 3) and (not re.search(P3, s)) else 'Invalid')


import re
for _ in range(int(input())):
	UID = input()
	isvalid = 'Invalid'
	if len(UID) == 10:
		count = 0
		matches = re.findall('(?:([0-9A-Za-z])(?!.*\\1))', UID)
		for match in matches:
			count += 1
		if count == 10:
			if re.search('(.*[0-9]+.*[0-9]+.*[0-9]+.*)', UID) != None:
				if re.search('(.*[A-Za-z]+.*[A-Za-z]+.*)', UID) != None:
					isvalid = 'Valid'
	print(isvalid)


import re
regex = re.compile('^(?=(?:.*[A-Z]){2})(?=(?:.*\\d){3})(?:([A-Za-z0-9])(?!.*\\1)){10}$')
N = int(input())
for _ in range(N):
	if bool(regex.match(input())) == True:
		print('Valid')
	else:
		print('Invalid')


import re

def is_valid(S):
	status = True
	if len(S) != 10:
		status = False
	m = re.search('[^a-zA-Z0-9]', S)
	if m is not None:
		status = False
	m = re.match('^.*?(\\d).*?(\\d).*?(\\d).*$', S)
	if m is None:
		status = False
	m = re.match('^.*?([A-Z]).*?([A-Z]).*$', S)
	if m is None:
		status = False
	m = re.search('(\\w).*\\1', S)
	if m is not None:
		status = False
	return status
for i in range(int(input())):
	if is_valid(input()):
		print('Valid')
	else:
		print('Invalid')


import re
for i in range(int(input())):
	inp = input().strip()
	if re.match('[A-Za-z0-9]{10}', inp) and re.search('[A-Z].*[A-Z]', inp) and re.search('[0-9].*[0-9].*[0-9]', inp) and (not re.search('([A-Za-z0-9]).*\\1', inp)):
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	r = 0
	s = input()
	if re.match('^[A-Za-z0-9]{10}$', s):
		r |= 17
	if re.search('[A-Z].*[A-Z]', s):
		r |= 2
	if re.search('\\d.*\\d.*\\d', s):
		r |= 4
	if not re.search('(.).*\\1', s):
		r |= 8
	print('Valid' if r == 31 else 'Invalid')


import re
N = int(input().strip())

def is_valid(uid):
	_ = re.search('^[A-Za-z0-9]{10}$', uid)
	if _ is None:
		return 'Invalid'
	_ = re.search('([A-Z].*){2}', uid)
	if _ is None:
		return 'Invalid'
	_ = re.search('([0-9].*){3}', uid)
	if _ is None:
		return 'Invalid'
	_ = re.search('(.).*\\1', uid)
	if _ is not None:
		return 'Invalid'
	return 'Valid'
for i in range(0, N):
	print(is_valid(input().strip()))


from collections import Counter

def validate(uid):
	if len(uid) != 10 or not uid.isalnum():
		return False
	if len(list(filter(lambda x: x.isupper(), uid))) < 2:
		return False
	if len(list(filter(lambda x: x.isdigit(), uid))) < 3:
		return False
	if any(filter(lambda x: x > 1, Counter(uid).values())):
		return False
	return True
print(*['Valid' if validate(input()) else 'Invalid' for _ in range(int(input()))], sep='\n')


import re
reg = [re.compile('^[A-Za-z0-9]{10}$'), re.compile('([A-Z].*){2}'), re.compile('([0-9].*){3}')]
reg1 = re.compile('(.).*\\1')
for _ in range(int(input())):
	s = input()
	print('Valid' if all([re.search(r, s) for r in reg]) and (not re.search(reg1, s)) else 'Invalid')


import re

def validate(uid):
	if not re.match('^[a-zA-Z0-9]{10}$', uid):
		return 'Invalid'
	if re.search('([a-zA-Z0-9]).*\\1', uid):
		return 'Invalid'
	if len(re.findall('[A-Z]', uid)) < 2:
		return 'Invalid'
	if len(re.findall('[0-9]', uid)) < 3:
		return 'Invalid'
	return 'Valid'
T = int(input())
for _ in range(T):
	print(validate(input()))


import re

def is_valid(s):
	if not re.search('[A-Z].*[A-Z]', s):
		return 'Invalid'
	if not re.search('[0-9].*[0-9].*[0-9]', s):
		return 'Invalid'
	if re.search('[^a-zA-Z0-9]', s):
		return 'Invalid'
	if re.search('(.).*\\1', s):
		return 'Invalid'
	if len(s) != 10:
		return 'Invalid'
	return 'Valid'
n_tests = int(input())
for _ in range(n_tests):
	print(is_valid(input().strip()))


import re
n = int(input())
for _ in range(n):
	v = input().strip()
	if len(v) == 10 and len(re.findall('[A-Z]', v)) >= 2 and (len(re.findall('[0-9]', v)) >= 3) and (len(set(list(v))) == 10):
		print('Valid')
	else:
		print('Invalid')


import re
n = int(input())
for _ in range(n):
	s = input()
	print('Valid' if all([re.search(r, s) for r in ['[A-Za-z0-9]{10}', '([A-Z].*){2}', '([0-9].*){3}']]) and (not re.search('.*(.).*\\1', s)) else 'Invalid')


from re import *
T = int(input())
for _ in range(T):
	U = input().strip()
	LengthAlphaN10U = bool(search('^[a-zA-Z0-9]{10}$', U))
	Ucase2U = bool(search('([A-Z].*){2}', U))
	Digits3U = bool(search('([0-9].*){3}', U))
	NoRepeatU = not bool(search('(.).*\\1', U))
	print('Valid' if LengthAlphaN10U and Ucase2U and Digits3U and NoRepeatU else 'Invalid')


import re
for i in range(int(input())):
	s = input().strip()
	if len(s) == 10 and len(re.findall('[A-Z]', s)) >= 2 and (len(re.findall('[0-9]', s)) >= 3) and re.search('[0-9a-zA-Z]{10}', s) and (not re.search('.*(.).*\\1', s)):
		print('Valid')
	else:
		print('Invalid')


import re
N = int(input())
uids = [input() for i in range(N)]
for uid in uids:
	nU = len(re.findall('[A-Z]', uid))
	nD = len(re.findall('\\d', uid))
	rpt = re.search('(?<=(\\w)).*\\1', uid)
	print('Valid' if nU >= 2 and nD >= 3 and uid.isalnum() and (rpt == None) and (len(uid) == 10) else 'Invalid')


import re
N = int(input())
for _ in range(N):
	S = input()
	if all([re.match('^[0-9A-Za-z]{10}$', S), bool(re.search('([A-Z].*){2,}', S)), bool(re.search('([0-9].*){3,}', S)), not bool(re.search('.*(.).*?\\1', S))]):
		print('Valid')
	else:
		print('Invalid')


import re
for i in range(int(input())):
	s = input()
	print('Valid' if all([re.search(r, s) for r in ['[A-Za-z0-9]{10}', '([A-Z].*){2}', '([0-9].*){3}']]) and (not re.search('.*(.).*\\1', s)) else 'Invalid')


import re
n = int(input())
for _ in range(n):
	s = input().strip()
	ok = True
	try:
		m = re.findall('[A-Z]', s)
		if len(m) < 2:
			raise Exception
		m = re.findall('[0-9]', s)
		if len(m) < 3:
			raise Exception
		m = re.match('^[A-Za-z0-9]*$', s)
		if not m:
			raise Exception
		m = re.search('([A-Za-z0-9]).*\\1', s)
		if m:
			raise Exception
		if len(s) != 10:
			raise Exception
	except:
		ok = False
	if ok:
		print('Valid')
	else:
		print('Invalid')


import re

def checkuid(x):
	r = True
	if len(x) != 10:
		r = False
	elif not bool(re.match('[a-z0-9]*', x, re.I)):
		r = False
	elif bool(re.search('.*(\\w).*\\1.*', x)):
		r = False
	elif not bool(re.search('.*\\d.*\\d.*\\d.*', x)):
		r = False
	elif not bool(re.search('.*[A-Z].*[A-Z].*', x)):
		r = False
	return r
L = [input().strip() for _ in range(int(input()))]
for x in L:
	if checkuid(x):
		print('Valid')
	else:
		print('Invalid')


def isValid(uid):
	(up, d, s) = (0, 0, set())
	for c in uid:
		up = up + 1 if c.isupper() else up
		d = d + 1 if c.isdigit() else d
		s.add(c)
	print('Valid' if up >= 2 and d >= 3 and uid.isalnum() and (len(s) == len(uid) == 10) else 'Invalid')
[isValid(input().rstrip()) for _ in range(int(input()))]


import re
T = int(input())
for each in range(T):
	s = input()
	m = re.search('[A-Z].*[A-Z]', s)
	if m == None:
		print('Invalid')
		continue
	m = re.search('\\d.*\\d.*\\d', s)
	if m == None:
		print('Invalid')
		continue
	m = re.search('^[A-z0-9]+$', s.strip())
	if m == []:
		print('Invalid')
		continue
	m = re.findall('(.).*\\1', s)
	if m != []:
		print('Invalid')
		continue
	if len(s.strip()) == 10:
		print('Valid')
	else:
		print('Invalid')


def solve():
	s = input().strip()
	u = len([c for c in s if c.isupper()])
	d = len([c for c in s if c.isdigit()])
	f = len([c for c in s if not c.isdigit and (not c.isalpha())])
	print('Valid' if u >= 2 and d >= 3 and (f == 0) and (len(set(s)) == 10) else 'Invalid')

def main():
	n = int(input())
	for _ in range(n):
		solve()
main()


import re
for _ in range(int(input())):
	s = input()
	regexList = ['([A-Z].*){2}', '([0-9].*){3}', '^[a-zA-Z0-9]{10}$']
	print('Valid' if all([re.search(r, s) for r in regexList]) and all([s[i] not in s[i + 1:] for i in range(len(s))]) else 'Invalid')


import re
test_pos = ['^[A-Za-z0-9]{10}$', '.*\\d.*\\d.*\\d', '.*[A-Z].*[A-Z]']
test_neg = ['.*([A-Za-z0-9]).*\\1']
for i in range(int(input())):
	s = input().strip()
	results = all([re.match(r, s) for r in test_pos])
	results = all([results, not all([re.match(r, s) for r in test_neg])])
	if results:
		print('Valid')
	else:
		print('Invalid')


import re
p1 = '^(?:([A-Za-z0-9])(?!.*\\1))*$'
p2 = '[A-Z]'
p3 = '[0-9]'
t = int(input())
for _ in range(t):
	s = input().strip()
	m1 = re.match(p1, s)
	m2 = len(re.findall(p2, s))
	m3 = len(re.findall(p3, s))
	if len(s) == 10 and m1 and (m2 >= 2) and (m3 >= 3):
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	s = input()
	print('Valid' if all([re.search(p, s) for p in ['^[a-zA-Z0-9]{10}$', '([A-Z].*){2}', '([0-9].*){3}']]) and (not re.search('.*(.).*\\1', s)) else 'Invalid')


import re
for _ in range(int(input())):
	s = input()
	if re.match('^(?:([A-Za-z0-9])(?!.*\\1)){10}$', s) is not None:
		uppercount = 0
		numcount = 0
		for c in s:
			if c.isupper():
				uppercount += 1
			elif c.isdigit():
				numcount += 1
		if numcount >= 3 and uppercount >= 2:
			print('Valid')
		else:
			print('Invalid')
	else:
		print('Invalid')


import re
p1 = re.compile('^.*[A-Z].*[A-Z].*$')
p2 = re.compile('^.*[0-9].*[0-9].*[0-9].*$')
p3 = re.compile('^[A-Za-z0-9]*$')
p4 = re.compile('^.*(.).*\\1.*$')
t = int(input())
for i in range(0, t):
	uid = input()
	if p1.match(uid) and p2.match(uid) and p3.match(uid) and (not p4.match(uid)) and (len(uid) == 10):
		print('Valid')
	else:
		print('Invalid')


import re
from collections import Counter
checkalphanum = re.compile('[^a-zA-Z0-9]')
checkupper = re.compile('[A-Z].*[A-Z]')
checkdigits = re.compile('[0-9].*[0-9].*[0-9]')
checkrepeats = re.compile('(.+)\\1+')
for k in range(int(input())):
	UID = input().strip()
	count = Counter(UID)
	if len(UID) == 10 and (not checkalphanum.search(UID)) and checkupper.search(UID) and checkdigits.search(UID) and (count.most_common(1)[0][1] <= 1):
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	s = input()
	print('Valid' if all([re.search(r, s) for r in ['[A-Za-z0-9]{10}', '([A-Z].*){2}', '([0-9].*){3}']]) and (not re.search('.*(.).*\\1', s)) else 'Invalid')


import re
r = '(?!.*(.).*\\1)(?=(.)(?!.*\\2))(?=.*[A-Z].*[A-Z])(?=.*[0-9].*[0-9].*[0-9])(?=[a-zA-Z0-9]{10}$)'
for _ in range(int(input())):
	t = input()
	print('Valid' if re.match(r, t) else 'Invalid')


import re
t = int(input())
regexes = ['([A-Z].*){2}', '([0-9].*){3}', '[a-zA-Z0-9]{10}', '.*(.).*\\1']
for _ in range(t):
	s = input()
	if all((re.search(regex, s) for regex in regexes[:-1])) and (not re.search(regexes[-1], s)):
		print('Valid')
	else:
		print('Invalid')


import sys, re
lines = int(input().strip())
for i in range(lines):
	UID = str(input().strip())
	if len(UID) != 10 or len(set(UID)) != 10 or re.search('[^A-Za-z0-9]', UID) or (len(re.findall('\\d', UID)) < 3) or (len(re.findall('[A-Z]', UID)) < 2):
		print('Invalid')
	else:
		print('Valid')


import re
t = int(input().strip())
for _ in range(t):
	print('Valid' if re.match('(?=(?:.*[A-Z]){2})(?=(?:.*[0-9]){3})^(?:([0-9A-Za-z])(?!.*\\1)){10}$', input()) else 'Invalid')


import re
N = int(input())
Caps = re.compile('(?=[A-Z]).')
digs = re.compile('(?=[0-9]).')
chr = re.compile('^(?=[A-Za-z0-9]).{10}$')
for i in range(N):
	S = input()
	if len(set(S)) == 10 and chr.match(S) and (len(digs.findall(S)) >= 3) and (len(Caps.findall(S)) >= 2):
		print('Valid')
	else:
		print('Invalid')


import re
for i in range(int(input())):
	uid = input()
	if re.fullmatch('(?=[A-Za-z0-9]{10})(.+)(?<!.{11})', uid):
		if sum((1 for l in uid if l.isupper())) >= 2:
			if sum((1 for l in uid if l.isdigit())) >= 3:
				for l in uid:
					if uid.count(l) > 1:
						print('Invalid')
						break
				else:
					print('Valid')
			else:
				print('Invalid')
		else:
			print('Invalid')
	else:
		print('Invalid')


import re
N = int(input())
for _ in range(N):
	t = input().strip()
	if re.search('[A-Z].*[A-Z]', t) != None and re.search('[0-9].*[0-9].*[0-9]', t) != None and (re.search('^[a-zA-Z0-9]*$', t) != None) and (re.search('(.).*\\1', t) == None) and (len(t) == 10):
		print('Valid')
	else:
		print('Invalid')


import re

def validUID(line):
	if len(line) != 10:
		return 'Invalid'
	if not bool(re.search('[A-Z].*[A-Z]', line)):
		return 'Invalid'
	if not bool(re.search('[0-9].*[0-9].*[0-9]', line)):
		return 'Invalid'
	if bool(re.search('[^0-9a-zA-Z]', line)):
		return 'Invalid'
	if bool(re.search('(.).*\\1', line)):
		return 'Invalid'
	return 'Valid'
N = int(input())
print(*[validUID(input()) for _ in range(N)], sep='\n')


import re

def check(str):
	m = all([re.search(r, str) for r in ['[A-Za-z0-9]{10}', '([A-Z].*){2}', '([0-9].*){3}']]) and (not re.search('(.).*\\1', str))
	if m:
		print('Valid')
	else:
		print('Invalid')
for i in range(int(input())):
	str = input()
	check(str)


valid = lambda uid: all((len(uid) == len(set(uid)) == 10, uid.isalnum(), sum(map(str.isupper, uid)) >= 2, sum(map(str.isdigit, uid)) >= 3))
for test in range(int(input())):
	print(('in' * (not valid(input())) + 'valid').capitalize())


import re
for i in range(int(input())):
	uid = input()
	if re.search('^[a-zA-Z0-9]{10}$', uid):
		flag = 1
		for r in range(10):
			if uid.count(uid[r]) == 1:
				continue
			else:
				flag = 0
				break
		if len(re.findall('[A-Z]', uid)) >= 2 and len(re.findall('[0-9]', uid)) >= 3 and flag:
			print('Valid')
		else:
			print('Invalid')
	else:
		print('Invalid')


import re
n = int(input())
upper_check = '.*([A-Z].*){2,}'
digit_check = '.*([0-9].*){3,}'
alphanumeric_and_length_check = '([A-Za-z0-9]){10}$'
repeat_check = '.*(.).*\\1'
for i in range(n):
	uid_string = input().strip()
	upper_check_result = bool(re.match(upper_check, uid_string))
	digit_check_result = bool(re.match(digit_check, uid_string))
	alphanumeric_and_length_check_result = bool(re.match(alphanumeric_and_length_check, uid_string))
	repeat_check_result = bool(re.match(repeat_check, uid_string))
	if upper_check_result and digit_check_result and alphanumeric_and_length_check_result and (not repeat_check_result):
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input().strip())):
	valid = True
	id = input().strip()
	if re.match('[a-zA-Z0-9]{10}', id) == None:
		valid = False
	elif re.search('([a-zA-Z0-9]{1}).*\\1{1}', id) != None:
		valid = False
	elif re.search('[0-9]{1}.*[0-9]{1}.*[0-9]{1}', id) == None:
		valid = False
	elif re.search('[A-Z]{1}.*[A-Z]{1}', id) == None:
		valid = False
	if valid:
		print('Valid')
	else:
		print('Invalid')


import re
n = int(input())
for i in range(n):
	text = input()
	unique_characters = len(''.join(set(text))) == len(text)
	if all([re.search(r, text) for r in ['[a-zA-Z0-9]{10}', '([A-Z].*){2}', '([0-9].*){3}']]) and unique_characters:
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	l = input()
	if len([c for c in l if c.isupper()]) < 2:
		print('Invalid')
	elif len([c for c in l if c.isdigit()]) < 3:
		print('Invalid')
	elif not re.match('[A-Za-z\\d]{10}', l):
		print('Invalid')
	elif len(set(l)) != len(l):
		print('Invalid')
	else:
		print('Valid')


import re
for _ in range(int(input())):
	s = input()
	if len(re.findall('[A-Z]', s)) >= 2 and len(re.findall('[0-9]', s)) >= 3 and re.match('^[a-zA-Z0-9]{10}$', s) and (len(s) == len(set(s))):
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	s = input()
	result = len(set(re.findall('[a-zA-Z0-9]', s))) == 10 and len(re.findall('[A-Z]', s)) > 1 and (len(re.findall('[0-9]', s)) > 2)
	print('Valid' if result else 'Invalid')


import re

def validate(uid_str):
	base = re.compile('\\b[a-zA-Z0-9]{10}\\b')
	re_tests = [re.compile('[A-Z].*[A-Z]'), re.compile('[0-9].*[0-9].*[0-9]')]
	if base.match(uid_str):
		for test in re_tests:
			if not test.search(uid_str):
				uid_str = None
				break
		if uid_str:
			for c in uid_str:
				if uid_str.count(c) > 1:
					uid_str = None
					break
	else:
		uid_str = None
	if uid_str:
		return 'Valid'
	else:
		return 'Invalid'
n = int(input())
for _ in range(n):
	print(validate(input()))


val1 = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
val2 = list('0123456789')
val = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
for _ in range(int(input())):
	ls = list(input().strip())
	st = set(ls)
	test = 'Invalid'
	if 10 == len(ls) and 10 == len(st):
		if 10 == len(list(filter(lambda x: x in val, ls))):
			if 1 < sum(list(map(lambda x: ls.count(x), val1))) < 8:
				if 2 < sum(list(map(lambda x: ls.count(x), val2))):
					test = 'Valid'
	print(test)


import sys
import re

def is_valid(s):
	if not re.search('^[\\w]{10,10}$', s):
		sys.stdout.write('Invalid\n')
		return
	if not re.search('[A-Z].*[A-Z]', s):
		sys.stdout.write('Invalid\n')
		return
	if not re.search('[0-9].*[0-9].*[0-9]', s):
		sys.stdout.write('Invalid\n')
		return
	if re.search('(?P<c>.).*(?P=c)+', s):
		sys.stdout.write('Invalid\n')
		return
	sys.stdout.write('Valid\n')
	return

def vn():
	num = int(sys.stdin.readline())
	while num:
		s = sys.stdin.readline()
		s = s.strip()
		is_valid(s)
		num -= 1
	return

def main():
	vn()
	return
main()


N = int(input())
insieme = set()
count_upper = 0
count_digit = 0
for i in range(N):
	stringa = input().strip()
	insieme.clear()
	count_upper = 0
	count_digit = 0
	for x in range(len(stringa)):
		insieme.add(stringa[x])
		if stringa[x].isdigit():
			count_digit = count_digit + 1
		if stringa[x].isupper():
			count_upper = count_upper + 1
	if len(insieme) != len(stringa) or len(stringa) != 10 or count_upper < 2 or (count_digit < 3):
		print('Invalid')
	else:
		print('Valid')


import re
for _ in range(int(input())):
	uid = input()
	check = all([len(re.findall('[A-Z]', uid)) >= 2, len(re.findall('\\d', uid)) >= 3, re.search('^[a-zA-Z0-9]{10}$', uid), not re.search('(\\w).*\\1', uid)])
	if check:
		print('Valid')
	else:
		print('Invalid')


import re

def __starting_point():
	t = int(input().strip())
	for _ in range(t):
		uid = ''.join(sorted(input()))
		if len(uid) == 10 and re.match('', uid) and re.search('[A-Z]{2}', uid) and re.search('\\d\\d\\d', uid) and (not re.search('[^a-zA-Z0-9]', uid)) and (not re.search('(.)\\1', uid)):
			print('Valid')
		else:
			print('Invalid')
__starting_point()


from collections import Counter
import re
for _ in range(int(input())):
	uid = input()
	if len(Counter(uid)) == 10 and re.match('^[a-zA-Z0-9]{10}$', uid) and (len(list(filter(lambda x: x.isupper(), uid))) >= 2) and (len(list(filter(lambda x: x.isdigit(), uid))) >= 3):
		print('Valid')
	else:
		print('Invalid')


n = int(input())
for i in range(n):
	s = input()
	if len(s) != 10:
		print('Invalid')
		continue
	d = {}
	num_count = 0
	big_count = 0
	for c in s:
		if not c.isalnum():
			print('Invalid')
			break
		elif c in d:
			print('Invalid')
			break
		else:
			if c.isupper():
				big_count += 1
			elif c.isdigit():
				num_count += 1
			d[c] = 1
	else:
		if num_count >= 3 and big_count >= 2:
			print('Valid')
		else:
			print('Invalid')


import re
from sys import exit
N = int(input())
for _ in range(N):
	UID = input()
	if len(UID) != 10 or len(set(UID)) != 10:
		print('Invalid')
		continue
	upper_count = len(re.findall('[A-Z]', UID))
	if upper_count < 2:
		print('Invalid')
		continue
	digit_count = len(re.findall('[0-9]', UID))
	if digit_count < 3:
		print('Invalid')
		continue
	allowed_exp_count = len(re.findall('[A-Za-z0-9]', UID))
	if allowed_exp_count != 10:
		print('Invalid')
		continue
	print('Valid')


import re
p = re.compile('(?=.*[A-Z]+.*[A-Z]+)(?=.*\\d+.*\\d+.*\\d+)(?=[a-zA-Z0-9]{10,10}$)(?!.*(.).*\\1)')
for i in range(int(input())):
	if bool(re.match(p, input())):
		print('Valid')
	else:
		print('Invalid')


import re

def validate(x):
	l = len(x)
	if l != 10:
		return 'Invalid'
	if l != len(set(x)):
		return 'Invalid'
	if not re.search('^[a-zA-Z0-9]{10}$', x):
		return 'Invalid'
	s = ''.join(sorted(x))
	if not re.search('[0-9]{3,}', s):
		return 'Invalid'
	u = re.findall('[A-Z]', x)
	if len(u) < 2:
		return 'Invalid'
	return 'Valid'
N = int(input())
for _ in range(N):
	print(validate(input()))


import re
for _ in range(int(input().strip())):
	S = input().strip()
	print('Valid' if all([re.search(x, S) for x in ['^[a-zA-Z0-9]{10}$', '([A-Z].*){2}', '([0-9].*){3}']]) and len(set(S)) == 10 else 'Invalid')


import re
for i in range(int(input())):
	print('Valid' if re.match('^(?=.{10}$)(?=.*[A-Z].*[A-Z])(?=.*[0-9].*[0-9].*[0-9])(?!.*(.).*\\1)[^\\W_]+$', input()) else 'Invalid')


for x in [input().strip() for _ in range(int(input()))]:
	if len(x) != 10:
		print('Invalid')
		continue
	upper = 0
	digit = 0
	last = []
	failed = False
	for char in x:
		if char in last:
			failed = True
			break
		if not char.isalnum():
			failed = True
			break
		if char.isdigit():
			digit += 1
		elif char.isupper():
			upper += 1
		last.append(char)
	if failed or digit < 3 or upper < 2:
		print('Invalid')
	else:
		print('Valid')


import re

def isValid(s):
	has10alnum = re.match('^([0-9a-z]){10}$', s, re.I)
	has2upalpha = len(re.findall('([A-Z])', s)) >= 2
	has3digits = len(re.findall('([0-9])', s)) >= 3
	isDuplicate = len(s) == len(set(s))
	return has10alnum and has2upalpha and has3digits and isDuplicate
for _ in range(int(input())):
	print('Valid' if isValid(input()) else 'Invalid')


import re
for _ in range(int(input())):
	s = input()
	print('Valid' if all([re.search(r, s) for r in ['^[A-Za-z0-9]{10}$', '([A-Z].*){2}', '([0-9].*){3}']]) and (not re.search('(.).*\\1', s)) else 'Invalid')


import re
for i in range(int(input())):
	UID = input()
	if len(UID) == 10 and UID.isalnum() and (len(re.findall('[A-Z]', UID)) >= 2) and (len(re.findall('[0-9]', UID)) >= 3) and (len(re.findall('([\\w\\d])([\\w\\d])*?\\1', UID)) == 0):
		print('Valid')
	else:
		print('Invalid')


import re
for _ in range(int(input())):
	s = input()
	print('Valid' if not re.search('(.).*\\1', s) and all([re.search(r, s) for r in ['([A-Z].*){2}', '([0-9].*){3}', '\\w(?!_){10}']]) else 'Invalid')


import re

def isValid(uid):
	return len(re.findall('[A-Z]', uid)) >= 2 and len(re.findall('[0-9]', uid)) >= 3 and re.match('[a-zA-Z0-9]{10}', uid) and (len(set(uid)) == len(uid))
for _ in range(int(input())):
	if isValid(input()):
		print('Valid')
	else:
		print('Invalid')


n = int(input().strip())
for i in range(n):
	line = input().strip()
	valid = False
	digitCount = 0
	capCount = 0
	if len(line) == 10:
		chars = {}
		valid = True
		for c in line:
			if c in chars or not c.isalnum():
				valid = False
			else:
				chars[c] = True
			if c.upper():
				capCount += 1
			if c.isdigit():
				digitCount += 1
			if not valid:
				break
	valid = valid and capCount >= 2 and (digitCount >= 3)
	print('Valid' if valid else 'Invalid')


import string
T = int(input())
for i in range(0, T):
	flag = True
	dic = {}
	UID = input()
	if len(UID) == 10:
		l = list(UID)
		for c in l:
			if c in dic:
				dic[c] = dic[c] + 1
			else:
				dic[c] = 1
		for (key, value) in dic.items():
			if value > 1:
				flag = False
				break
		ucounter = 0
		for c in UID:
			if c.isupper():
				ucounter = ucounter + 1
		dcounter = 0
		for c in UID:
			if c.isdigit():
				dcounter = dcounter + 1
		if dcounter >= 3 and ucounter >= 2:
			for c in UID:
				if c in string.ascii_letters + string.digits:
					pass
				else:
					flag = False
					break
		else:
			flag = False
	else:
		flag = False
	if flag == True:
		print('Valid')
	else:
		print('Invalid')


import re
numre = re.compile('\\d')
UPalphare = re.compile('[A-Z]')
alnum10re = re.compile('[a-zA-Z0-9]{10}')

def is_valid_uid(s):
	return len(s) == 10 and len(set(s)) == 10 and alnum10re.match(s) and (len(numre.findall(s)) >= 3) and (len(UPalphare.findall(s)) >= 2)
for _ in range(int(input())):
	print('Valid' if is_valid_uid(input()) else 'Invalid')


import re
pattern = '(?=(.*[A-Z]){3})(?=(.*\\d){3})'
N = int(input())
for _ in range(N):
	s = input()
	m = re.search('[A-Za-z0-9]{10}', s) and re.search('([A-Z].*){2}', s) and re.search('([0-9].*){3}', s) and (not re.search('.*(.).*\\1', s))
	if m:
		print('Valid')
	else:
		print('Invalid')


import re
N = int(input())
for i in range(N):
	S = input()
	unique = len(S) != 0 and len(set(S)) == len(S)
	alphanumeric = re.match('[A-z\\d]{10}', S)
	capitals = re.search('([A-Z].*){2}', S)
	digits = re.search('([\\d].*){3}', S)
	if unique and alphanumeric and digits and capitals:
		print('Valid')
	else:
		print('Invalid')


import re
num = []
N = int(input())
Caps = re.compile('(?=[A-Z]).')
digs = re.compile('(?=[0-9]).')
char = re.compile('^(?=[A-Za-z0-9]).{10}$')
for i in range(N):
	num.append(input())
for k in range(len(num)):
	if len(set(num[k])) == 10 and char.match(num[k]) and (len(digs.findall(num[k])) >= 3) and (len(Caps.findall(num[k])) >= 2):
		print('Valid')
	else:
		print('Invalid')


def rep(d):
	for v in d.values():
		if v > 1:
			return True
	return False

def result(uid):
	if len(uid) != 10:
		return 'Invalid'
	uca = {}
	lca = {}
	n = {}
	for r in uid:
		if r >= 'A' and r <= 'Z':
			d = uca
		elif r >= 'a' and r <= 'z':
			d = lca
		elif r >= '0' and r <= '9':
			d = n
		else:
			return 'Invalid'
		if r in d:
			d[r] = d[r] + 1
		else:
			d[r] = 1
	return 'Valid' if len(uca) >= 2 and len(n) >= 3 and (not rep(uca)) and (not rep(lca)) and (not rep(n)) else 'Invalid'
for _ in range(int(input())):
	uid = input().strip()
	print(result(uid))