Vasya came up with a password to register for EatForces — a string s. The password in EatForces should be a string, consisting of lowercase and uppercase Latin letters and digits.

But since EatForces takes care of the security of its users, user passwords must contain at least one digit, at least one uppercase Latin letter and at least one lowercase Latin letter. For example, the passwords "abaCABA12", "Z7q" and "3R24m" are valid, and the passwords "qwerty", "qwerty12345" and "Password" are not. 

A substring of string s is a string x = s_l s_{l + 1} ... s_{l + len - 1} (1 ≤ l ≤ |s|, 0 ≤ len ≤ |s| - l + 1). len is the length of the substring. Note that the empty string is also considered a substring of s, it has the length 0.

Vasya's password, however, may come too weak for the security settings of EatForces. He likes his password, so he wants to replace some its substring with another string of the same length in order to satisfy the above conditions. This operation should be performed exactly once, and the chosen string should have the minimal possible length.

Note that the length of s should not change after the replacement of the substring, and the string itself should contain only lowercase and uppercase Latin letters and digits.

Input

The first line contains a single integer T (1 ≤ T ≤ 100) — the number of testcases.

Each of the next T lines contains the initial password s~(3 ≤ |s| ≤ 100), consisting of lowercase and uppercase Latin letters and digits.

Only T = 1 is allowed for hacks.

Output

For each testcase print a renewed password, which corresponds to given conditions. 

The length of the replaced substring is calculated as following: write down all the changed positions. If there are none, then the length is 0. Otherwise the length is the difference between the first and the last changed position plus one. For example, the length of the changed substring between the passwords "abcdef" → "a7cdEf" is 4, because the changed positions are 2 and 5, thus (5 - 2) + 1 = 4.

It is guaranteed that such a password always exists.

If there are several suitable passwords — output any of them.

Example

Input

2
abcDCE
htQw27


Output

abcD4E
htQw27

Note

In the first example Vasya's password lacks a digit, he replaces substring "C" with "4" and gets password "abcD4E". That means, he changed the substring of length 1.

In the second example Vasya's password is ok from the beginning, and nothing has to be changed. That is the same as replacing the empty substring with another empty substring (length 0).

Difficulty: EASY

Solutions:
import math
t = int(input())
for j in range(t):
	s = input()
	f1 = f2 = f3 = 0
	c1 = c2 = c3 = 0
	for i in range(len(s)):
		l = s[i]
		if l.isupper():
			f1 = 1
			c1 += 1
		elif l.islower():
			f2 = 1
			c2 += 1
		else:
			f3 = 1
			c3 += 1
	if f1 and f2 and f3:
		print(s)
	elif f1 and f2:
		for i in range(len(s)):
			l = s[i]
			if l.isupper() and c1 > 1 or (l.islower() and c2 > 1):
				print(s[:i] + '1' + s[i + 1:])
				break
	elif f1 and f3:
		for i in range(len(s)):
			l = s[i]
			if l.isupper() and c1 > 1 or (not l.isupper() and c3 > 1):
				print(s[:i] + 'a' + s[i + 1:])
				break
	elif f3 and f2:
		for i in range(len(s)):
			l = s[i]
			if c2 > 1 and l.islower() or (not l.islower() and c3 > 1):
				print(s[:i] + 'A' + s[i + 1:])
				break
	elif f1:
		print('a1' + s[2:])
	elif f2:
		print('A1' + s[2:])
	elif f3:
		print('aA' + s[2:])


import sys

def is_valid(s):
	lower = 'qwertyuioplkjhgfdsazxcvbnm'
	upper = 'QWERTYUIOPLKJHGFDSAZXCVBNM'
	digits = '1234567890'
	l = False
	u = False
	d = False
	for c in s:
		if c in upper:
			u = True
		elif c in lower:
			l = True
		else:
			d = True
	return l and u and d

def main():
	for case in range(int(input())):
		s = input()
		series = [c for c in s]
		ans = False
		if is_valid(series):
			print(s)
		else:
			for i in range(len(s)):
				temp = [c for c in series]
				temp[i] = 'a'
				if is_valid(temp):
					print(''.join(temp))
					ans = True
					break
				temp = [c for c in series]
				temp[i] = 'A'
				if is_valid(temp):
					print(''.join(temp))
					ans = True
					break
				temp = [c for c in series]
				temp[i] = '1'
				if is_valid(temp):
					print(''.join(temp))
					ans = True
					break
			if ans == False:
				if series[0] in 'qwertyuioplkjhgfdsazxcvbnm':
					print('A1', end='')
					print(s[2:])
				elif series[0] in 'QWERTYUIOPLKJHGFDSAZXCVBNM':
					print('a1', end='')
					print(s[2:])
				else:
					print('aA', end='')
					print(s[2:])
main()


t = int(input())
for u in range(t):
	s = input()
	alph = 'abcdefghijklmnopqrstuvwxyz'
	ALPH = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
	num = '1234567890'
	counts = [0, 0, 0]
	for char in s:
		if char in alph:
			counts[0] += 1
		elif char in num:
			counts[2] += 1
		else:
			counts[1] += 1
	if counts[0] > 0 and counts[1] > 0 and (counts[2] > 0):
		print(s)
	elif counts[0] == counts[1] == 0:
		print('aA' + s[2:])
	elif counts[0] == counts[2] == 0:
		print('a1' + s[2:])
	elif counts[1] == counts[2] == 0:
		print('A1' + s[2:])
	elif counts[0] == 0:
		if counts[1] > 1:
			for i in range(len(s)):
				if s[i] in ALPH:
					print(s[:i] + 'a' + s[i + 1:])
					break
		else:
			for i in range(len(s)):
				if s[i] in num:
					print(s[:i] + 'a' + s[i + 1:])
					break
	elif counts[1] == 0:
		if counts[0] > 1:
			for i in range(len(s)):
				if s[i] in alph:
					print(s[:i] + 'A' + s[i + 1:])
					break
		else:
			for i in range(len(s)):
				if s[i] in num:
					print(s[:i] + 'A' + s[i + 1:])
					break
	elif counts[0] > 1:
		for i in range(len(s)):
			if s[i] in alph:
				print(s[:i] + '1' + s[i + 1:])
				break
	else:
		for i in range(len(s)):
			if s[i] in ALPH:
				print(s[:i] + '1' + s[i + 1:])
				break


n = int(input())
alph = 'abcdefghijklmnopqrstuvwxyz'
digit = '0123456789'
for i in range(n):
	st = input()
	key = True
	a = 0
	b = 0
	c = 0
	for k in st:
		if k not in alph:
			key = False
		else:
			a = a + 1
		if k not in alph.upper():
			key = False
		else:
			b = b + 1
		if k not in digit:
			key = False
		else:
			c = c + 1
	res = ''
	if not key:
		if a == 0:
			key = False
			if b > 1:
				for j in range(len(st)):
					if st[j] in alph.upper():
						st = st[0:j] + 'a' + st[j + 1:]
						key = True
						break
			if c > 1 and (not key):
				for j in range(len(st)):
					if st[j] in digit:
						st = st[0:j] + 'a' + st[j + 1:]
						key = True
						break
		if b == 0:
			key = False
			if a > 1:
				for j in range(len(st)):
					if st[j] in alph:
						st = st[0:j] + 'A' + st[j + 1:]
						key = True
						break
			if c > 1 and (not key):
				for j in range(len(st)):
					if st[j] in digit:
						st = st[0:j] + 'A' + st[j + 1:]
						key = True
						break
		if c == 0:
			key = False
			if a > 1:
				for j in range(len(st)):
					if st[j] in alph:
						st = st[0:j] + '1' + st[j + 1:]
						key = True
						break
			if b > 1 and (not key):
				for j in range(len(st)):
					if st[j] in alph.upper():
						st = st[0:j] + '1' + st[j + 1:]
						key = True
						break
	print(st)


n = int(input())

def cor(s):
	s = list(s)
	a = 0
	A = 0
	n = 0
	for j in range(len(s)):
		l = s[j]
		if ord('a') <= ord(l) and ord(l) <= ord('z'):
			a += 1
		elif ord('A') <= ord(l) and ord(l) <= ord('Z'):
			A += 1
		else:
			n += 1
	if a > 0 and A > 0 and (n > 0):
		return 1
	else:
		return 0

def solve(s):
	s = list(s)
	if cor(s) == 1:
		return s
	for j in range(len(s)):
		c = s[:]
		c[j] = 'a'
		if cor(c) == 1:
			return c
		c[j] = 'A'
		if cor(c) == 1:
			return c
		c[j] = '1'
		if cor(c) == 1:
			return c
	a = 0
	A = 0
	n = 0
	for j in range(len(s)):
		l = s[j]
		if ord('a') <= ord(l) and ord(l) <= ord('z'):
			a += 1
		elif ord('A') <= ord(l) and ord(l) <= ord('Z'):
			A += 1
		else:
			n += 1
	if a == 0 and A == 0:
		s[0] = 'a'
		s[1] = 'A'
		return s
	if a == 0 and n == 0:
		s[0] = 'a'
		s[1] = '1'
		return s
	else:
		s[0] = 'A'
		s[1] = '1'
		return s
for i in range(n):
	print(*solve(input()), sep='')


t = int(input())
result = []
low = 'abcdefghijklmnopqrstuvwxyz'
upp = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
number = '0123456789'
for i in range(t):
	is_lower = 0
	is_upper = 0
	is_number = 0
	s = input()
	for i in s:
		if i in low:
			is_lower += 1
		elif i in number:
			is_number += 1
		elif i in upp:
			is_upper += 1
	if is_lower > 0 and is_upper > 0 and (is_number > 0):
		print(s)
	elif is_lower == 0 and is_upper == 0:
		print('aA' + s[2:])
	elif is_lower == 0 and is_number == 0:
		print('a1' + s[2:])
	elif is_upper == 0 and is_number == 0:
		print('A1' + s[2:])
	elif is_lower == 0:
		if is_upper > 1:
			for i in range(len(s)):
				if s[i] in upp:
					print(s[:i] + 'a' + s[i + 1:])
					break
		else:
			for i in range(len(s)):
				if s[i] in number:
					print(s[:i] + 'a' + s[i + 1:])
					break
	elif is_upper == 0:
		if is_lower > 1:
			for i in range(len(s)):
				if s[i] in low:
					print(s[:i] + 'A' + s[i + 1:])
					break
		else:
			for i in range(len(s)):
				if s[i] in number:
					print(s[:i] + 'A' + s[i + 1:])
					break
	elif is_number == 0:
		if is_lower > 1:
			for i in range(len(s)):
				if s[i] in low:
					print(s[:i] + '1' + s[i + 1:])
					break
		else:
			for i in range(len(s)):
				if s[i] in upp:
					print(s[:i] + '1' + s[i + 1:])
					break


from sys import stdin
max_val = int(10000000000000.0)
min_val = int(-10000000000000.0)

def read_int():
	return int(stdin.readline())

def read_ints():
	return [int(x) for x in stdin.readline().split()]

def read_str():
	return input()

def read_strs():
	return [x for x in stdin.readline().split()]

def get_id(a):
	c_id = 2
	if 'a' <= a <= 'z':
		c_id = 0
	if 'A' <= a <= 'Z':
		c_id = 1
	return c_id
nb_test = read_int()
for _ in range(nb_test):
	replacement = ['a', 'A', '1']
	password = [x for x in input()]
	c_counts = [0] * 3
	for i in password:
		c_counts[get_id(i)] += 1
	for (i, v) in enumerate(password):
		ids = get_id(v)
		if c_counts[ids] > 1:
			for j in range(3):
				if not c_counts[j]:
					password[i] = replacement[j]
					c_counts[ids] -= 1
					c_counts[j] += 1
					break
	print(''.join(password))


n = int(input())
for i in range(n):
	s = input()
	(a, b, c) = (0, 0, 0)
	for (j, x) in enumerate(s):
		if x >= 'a' and x <= 'z':
			a += 1
		elif x >= 'A' and x <= 'Z':
			b += 1
		else:
			c += 1
	if a == 0 and b > 0 and (c > 0):
		if b == 1 and c > 1:
			if s[0] >= 'A' and s[0] <= 'Z':
				print(s[0] + 'a' + s[2:])
			else:
				print('a' + s[1:])
		elif b > 1 and c == 1:
			if s[0] >= 'A' and s[0] <= 'Z':
				print('a' + s[1:])
			else:
				print(s[0] + 'a' + s[2:])
		else:
			print('a' + s[1:])
	elif a > 0 and b == 0 and (c > 0):
		if a == 1 and c > 1:
			if s[0] >= 'a' and s[0] <= 'z':
				print(s[0] + 'A' + s[2:])
			else:
				print('A' + s[1:])
		elif a > 1 and c == 1:
			if s[0] >= 'a' and s[0] <= 'z':
				print('A' + s[1:])
			else:
				print(s[0] + 'A' + s[2:])
		else:
			print('A' + s[1:])
	elif a > 0 and b > 0 and (c == 0):
		if a == 1 and b > 1:
			if s[0] >= 'a' and s[0] <= 'z':
				print(s[0] + '1' + s[2:])
			else:
				print('1' + s[1:])
		elif a > 1 and b == 1:
			if s[0] >= 'a' and s[0] <= 'z':
				print('1' + s[1:])
			else:
				print(s[0] + '1' + s[2:])
		else:
			print('1' + s[1:])
	elif a == 0 and b == 0 and (c > 0):
		print('a' + 'A' + s[2:])
	elif a == 0 and b > 0 and (c == 0):
		print('a' + '1' + s[2:])
	elif a > 0 and b == 0 and (c == 0):
		print('A' + '1' + s[2:])
	else:
		print(s)


n = int(input())
A = [input() for i in range(n)]
for S in A:
	lower = 0
	upper = 0
	digit = 0
	ans = S
	for (i, s) in enumerate(S):
		if s.islower():
			lower += 1
		elif s.isupper():
			upper += 1
		else:
			digit += 1
	if lower and upper and digit:
		print(S)
		continue
	B = []
	if lower == 0:
		B.append('a')
	if upper == 0:
		B.append('A')
	if digit == 0:
		B.append('1')
	C = 0
	if ans[C].islower() and lower == 1 or (ans[C].isupper() and upper == 1) or (ans[C].isnumeric() and digit == 1):
		C += 1
	for b in B:
		ans = ans[:C] + b + ans[C + 1:]
		C += 1
	print(ans)


def isvalid(c):
	lower = False
	upper = False
	number = False
	for j in c:
		if j.isupper():
			upper = True
		if j.islower():
			lower = True
		if j.isnumeric():
			number = True
	if upper and lower and number:
		return True
	else:
		return False
t = int(input())
for i in range(t):
	s = input()
	if isvalid(s):
		print(s)
	else:
		for j in range(len(s)):
			temp = s[:j] + 'a' + s[j + 1:]
			if isvalid(temp):
				s = temp
				break
			temp = s[:j] + 'A' + s[j + 1:]
			if isvalid(temp):
				s = temp
				break
			temp = s[:j] + '1' + s[j + 1:]
			if isvalid(temp):
				s = temp
				break
		if isvalid(s):
			print(s)
		elif s[2].islower():
			s = 'A1' + s[2:]
			print(s)
		elif s[2].isupper():
			s = 'a1' + s[2:]
			print(s)
		else:
			s = 'aA' + s[2:]
			print(s)


T = int(input())
for _ in range(T):
	string = input()
	low = 0
	up = 0
	dig = 0
	flow = 0
	fup = 0
	fdig = 0
	for i in string:
		if i.islower() is True:
			low += 1
			if low == 1:
				flow = i
		elif i.isupper() is True:
			up += 1
			if up == 1:
				fup = i
		elif i.isdigit() is True:
			dig += 1
			if dig == 1:
				fdig = i
	if low * up * dig > 0:
		print(string)
	elif up * dig > 0:
		if dig == 1 and fdig == string[0]:
			print(string[0] + 'a' + string[2:])
		elif up == 1 and fup == string[0]:
			print(string[0] + 'a' + string[2:])
		else:
			print('a' + string[1:])
	elif up * low > 0:
		if low == 1 and flow == string[0]:
			print(string[0] + '1' + string[2:])
		elif up == 1 and fup == string[0]:
			print(string[0] + '1' + string[2:])
		else:
			print('1' + string[1:])
	elif dig * low > 0:
		if low == 1 and flow == string[0]:
			print(string[0] + 'A' + string[2:])
		elif dig == 1 and fdig == string[0]:
			print(string[0] + 'A' + string[2:])
		else:
			print('A' + string[1:])
	elif dig > 0:
		print('aA' + string[2:])
	elif up > 0:
		print('a1' + string[2:])
	else:
		print('A1' + string[2:])


T = int(input())
while T > 0:
	s = input()
	count1 = 0
	count2 = 0
	count3 = 0
	nums = []
	caps = []
	sms = []
	for a in s:
		if a.isupper() == True:
			count1 += 1
			caps.append(a)
		elif a.islower() == True:
			count2 += 1
			sms.append(a)
		elif a.isdigit() == True:
			count3 += 1
			nums.append(a)
	s = list(s)
	if count3 >= 1 and count2 >= 1 and (count1 >= 1):
		print(''.join(s))
	elif count1 >= 1 and count2 >= 1:
		if count2 >= 2:
			s[s.index(sms[0])] = '1'
		else:
			s[s.index(caps[0])] = '1'
		print(''.join(s))
	elif count2 >= 1 and count3 >= 1:
		if count2 >= 2:
			s[s.index(sms[0])] = 'A'
		else:
			s[s.index(nums[0])] = 'A'
		print(''.join(s))
	elif count1 >= 1 and count3 >= 1:
		if count1 >= 2:
			s[s.index(caps[0])] = 'a'
		else:
			s[s.index(nums[0])] = 'a'
		print(''.join(s))
	elif count1 >= 1:
		s[0] = 'a'
		s[1] = '1'
		print(''.join(s))
	elif count2 >= 1:
		s[0] = 'A'
		s[1] = '1'
		print(''.join(s))
	elif count3 >= 1:
		s[0] = 'a'
		s[1] = 'A'
		print(''.join(s))
	T -= 1


def strong(password):
	lower = False
	upper = False
	digit = False
	for c in password:
		if c.islower():
			lower = True
		if c.isupper():
			upper = True
		if c.isdigit():
			digit = True
	return lower and upper and digit
T = int(input())
passwords = ['' for _ in range(T)]
for t in range(T):
	passwords[t] = list(input())
newpasswords = ['' for _ in range(T)]
for (i, password) in enumerate(passwords):
	if strong(password):
		newpasswords[i] = password
	else:
		isOk = False
		for s in ['a', 'A', '1']:
			if isOk:
				break
			for j in range(len(password)):
				trypassword = password.copy()
				trypassword[j] = s
				if strong(trypassword):
					newpasswords[i] = trypassword
					isOk = True
					break
		for s in ['aA', 'a1', 'A1']:
			if isOk:
				break
			for j in range(len(password) - 1):
				trypassword = password.copy()
				trypassword[j:j + 2] = s
				if strong(trypassword):
					newpasswords[i] = trypassword
					isOk = True
					break
for password in newpasswords:
	print(''.join(password))


n = int(input())

def func(s):
	sta = False
	stA = False
	st1 = False
	posa = -1
	posA = -1
	pos1 = -1
	k = len(s)
	for i in range(k):
		t = ord(s[i])
		if t <= 57 and t >= 48:
			st1 = True
			pos1 = i
		elif t >= 65 and t <= 90:
			stA += 1
			posA = i
		else:
			sta += 1
			posa = i
	if st1 and sta and stA:
		return s
	else:
		res = ''
		for i in range(k):
			if i != pos1 and i != posa and (i != posA):
				if not sta:
					res += 'a'
					posa = i
					sta = True
				elif not stA:
					res += 'A'
					posA = i
					stA = True
				elif not st1:
					res += '1'
					pos1 = i
					st1 = True
				else:
					res += s[i]
			else:
				res += s[i]
		return res
for i in range(n):
	s = input()
	print(func(s))


import re
numTestCases = int(input())

def isValid(pwd):
	hasUpper = re.search('[A-Z]', pwd)
	hasLower = re.search('[a-z]', pwd)
	hasDigit = re.search('[0-9]', pwd)
	if hasUpper and hasLower and hasDigit:
		return True
	return False
for i in range(numTestCases):
	pwd = input()
	if isValid(pwd):
		print(pwd)
	else:
		newPwd = ''
		for i in range(len(pwd)):
			pwdList = list(pwd)
			pwdList[i] = 'a'
			if isValid(''.join(pwdList)):
				newPwd = ''.join(pwdList)
				break
			pwdList[i] = 'A'
			if isValid(''.join(pwdList)):
				newPwd = ''.join(pwdList)
				break
			pwdList[i] = '1'
			if isValid(''.join(pwdList)):
				newPwd = ''.join(pwdList)
				break
		if not newPwd:
			if pwd[2].isupper():
				newPwd = 'a1' + pwd[2:]
			elif pwd[2].islower():
				newPwd = 'A1' + pwd[2:]
			else:
				newPwd = 'aA' + pwd[2:]
		print(newPwd)


from collections import defaultdict
t = int(input().rstrip())
for _ in range(t):
	s = list(input().strip())
	n = len(s)
	c = defaultdict(int)
	a = [0] * n
	for i in range(n):
		if s[i] >= 'a':
			c[1] += 1
			a[i] = 1
		elif s[i] >= 'A':
			c[2] += 1
			a[i] = 2
		else:
			c[3] += 1
			a[i] = 3
	if not c[1] and (not c[2]):
		s[0] = 'a'
		s[1] = 'A'
	elif not c[1] and (not c[3]):
		s[0] = 'a'
		s[1] = '1'
	elif not c[2] and (not c[3]):
		s[0] = 'A'
		s[1] = '1'
	elif not c[1]:
		if c[a[0]] > 1:
			s[0] = 'a'
		else:
			s[1] = 'a'
	elif not c[2]:
		if c[a[0]] > 1:
			s[0] = 'A'
		else:
			s[1] = 'A'
	elif not c[3]:
		if c[a[0]] > 1:
			s[0] = '1'
		else:
			s[1] = '1'
	print(''.join(s))


def main():
	n = int(input(''))
	lista = []
	minus = False
	mayuscula = False
	numero = False
	cambio = False
	cambio2 = False
	cambio3 = False
	anteriorEstado = []
	estado = []
	while n > 0:
		palabra = input('')
		lista = junto(palabra)
		wordlist = list(palabra)
		minus = lista[0]
		mayuscula = lista[1]
		numero = lista[2]
		palabra = calcular(minus, mayuscula, numero, wordlist, palabra)
		n -= 1
		print(palabra)

def calcular(minus, mayuscula, numero, wordlist, palabra):
	if minus and mayuscula and numero:
		return palabra
	if minus == False:
		cambio = False
		for x in range(len(wordlist)):
			anteriorEstado = junto(palabra)
			letra = wordlist[x]
			if cambio == False:
				wordlist[x] = 'a'
				palabra = ''.join(wordlist)
				estado = junto(palabra)
				cambio = True
			if estado[0] and estado[1] and estado[2]:
				return palabra
			if estado[2] == anteriorEstado[2] and estado[1] == anteriorEstado[1]:
				continue
			else:
				wordlist[x] = letra
				cambio = False
	if mayuscula == False:
		cambio2 = False
		for x in range(len(wordlist)):
			anteriorEstado = junto(palabra)
			letra = wordlist[x]
			if cambio2 == False:
				wordlist[x] = 'A'
				palabra = ''.join(wordlist)
				estado = junto(palabra)
				cambio2 = True
			if estado[0] and estado[1] and estado[2]:
				return palabra
			if estado[0] == anteriorEstado[0] and estado[2] == anteriorEstado[2]:
				continue
			else:
				wordlist[x] = letra
				cambio2 = False
	if numero == False:
		cambio3 = False
		for x in range(len(wordlist)):
			anteriorEstado = junto(palabra)
			letra = wordlist[x]
			if cambio3 == False:
				wordlist[x] = '1'
				palabra = ''.join(wordlist)
				estado = junto(palabra)
				cambio3 = True
			if estado[0] and estado[1] and estado[2]:
				return palabra
			if estado[0] == anteriorEstado[0] and estado[1] == anteriorEstado[1]:
				continue
			else:
				wordlist[x] = letra
				cambio3 = False

def junto(palabra):
	lis = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'ñ', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']
	lis2 = ['A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'Ñ', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z']
	lista = list(palabra)
	boo1 = False
	boo2 = False
	boo3 = False
	for x in range(len(lista)):
		if lista[x] in lis and boo1 == False:
			boo1 = True
		elif lista[x] in lis2 and boo2 == False:
			boo2 = True
		elif lista[x].isdigit() and boo3 == False:
			boo3 = True
		if boo1 and boo2 and boo3:
			return (boo1, boo2, boo3)
	return (boo1, boo2, boo3)
main()


low = ''
for i in range(97, 97 + 26, 1):
	low += chr(i)
up = ''
for i in range(65, 65 + 26):
	up += chr(i)
dig = ''
for i in range(48, 49 + 9):
	dig += chr(i)
r = input
n = int(r())
res = ''
for i in range(n):
	rs = str(r())
	s = [x.strip() for x in rs]
	(fl, ll, fu, lu, fd, ld) = (-1, -1, -1, -1, -1, -1)
	cnt = 0
	res = ''
	for c in s:
		if c in low:
			if fl == -1:
				fl = cnt
				ll = cnt
			else:
				ll = cnt
		elif c in up:
			if fu == -1:
				fu = cnt
				lu = cnt
			else:
				lu = cnt
		if c in dig:
			if fd == -1:
				fd = cnt
				ld = cnt
			else:
				ld = cnt
		cnt += 1
	if fl != -1 and fu != -1 and (fd != -1):
		for i in s:
			res += i
		print(res)
	else:
		if fl == -1 and fu == -1:
			s[fd] = 'a'
			s[fd + 1] = 'A'
		elif fu == -1 and fd == -1:
			s[fl] = 'A'
			s[fl + 1] = '1'
		elif fl == -1 and fd == -1:
			s[fu] = 'a'
			s[fu + 1] = '1'
		elif fl != -1 and fu != -1:
			if fl != ll:
				s[fl] = '1'
			else:
				s[fu] = '1'
		elif fu != -1 and fd != -1:
			if fu != lu:
				s[fu] = 'a'
			else:
				s[fd] = 'a'
		elif fl != -1 and fd != -1:
			if fl != ll:
				s[fl] = 'A'
			else:
				s[fd] = 'A'
		for i in s:
			res += i
		print(res)


import sys

def rint():
	return map(int, sys.stdin.readline().split())
T = int(input())
type_char = ['a', 'A', '1']
for i in range(T):
	s = list(input())
	t = []
	for c in s:
		if c.islower():
			t.append(0)
		elif c.isupper():
			t.append(1)
		else:
			t.append(2)
	none_type = []
	for j in range(3):
		if not j in t:
			none_type.append(j)
	if len(none_type) == 1:
		for j in range(len(s)):
			if t.count(t[j]) >= 2:
				s[j] = type_char[none_type[0]]
				break
	elif len(none_type) == 2:
		s[0] = type_char[none_type[0]]
		s[1] = type_char[none_type[1]]
	print(''.join(s))


def get_counts(strng):
	counts = [0, 0, 0]
	lngth = len(strng)
	for i in range(lngth):
		cur_val = ord(strng[i])
		if cur_val >= 65 and cur_val <= 90:
			counts[1] += 1
		elif cur_val >= 97 and cur_val <= 122:
			counts[0] += 1
		elif cur_val >= 48 and cur_val <= 57:
			counts[2] += 1
	return counts

def correct_pass(strng):
	counts = get_counts(strng)
	n = len(strng)
	if counts[0] == 0:
		for i in range(n):
			cur_val = ord(strng[i])
			if cur_val >= 65 and cur_val <= 90 and (counts[1] > 1):
				strng[i] = 'a'
				counts[0] = 1
				counts[1] -= 1
				break
			if cur_val >= 48 and cur_val <= 57 and (counts[2] > 1):
				strng[i] = 'a'
				counts[0] = 1
				counts[2] -= 1
				break
	if counts[1] == 0:
		for i in range(n):
			cur_val = ord(strng[i])
			if cur_val >= 97 and cur_val <= 122 and (counts[0] > 1):
				strng[i] = 'A'
				counts[1] = 1
				counts[0] -= 1
				break
			if cur_val >= 48 and cur_val <= 57 and (counts[2] > 1):
				strng[i] = 'A'
				counts[1] = 1
				counts[2] -= 1
				break
	if counts[2] == 0:
		for i in range(n):
			cur_val = ord(strng[i])
			if cur_val >= 97 and cur_val <= 122 and (counts[0] > 1):
				strng[i] = '1'
				counts[2] = 1
				counts[0] -= 1
				break
			if cur_val >= 65 and cur_val <= 90 and (counts[1] > 1):
				strng[i] = '1'
				counts[2] = 1
				counts[1] -= 1
				break
	return strng
n = int(input())
strs = []
for i in range(n):
	strs.append(list(input()))
results = []
for i in range(n):
	print(''.join(correct_pass(strs[i])))


from sys import stdin, stdout
from math import gcd, ceil, sqrt
ii1 = lambda : int(stdin.readline().strip())
is1 = lambda : stdin.readline().strip()
iia = lambda : list(map(int, stdin.readline().strip().split()))
isa = lambda : stdin.readline().strip().split()
mod = 1000000007

def check(s):
	res = [0, 0, 0]
	for i in s:
		if i.islower():
			res[0] = 1
		elif i.isupper():
			res[1] = 1
		else:
			res[2] = 1
		if sum(res) == 3:
			return [True]
	return [False, res]
tc = ii1()
for _ in range(tc):
	s = is1()
	chk = check(s)
	if chk[0]:
		print(s)
	else:
		s1 = ''
		for i in range(3):
			if i == 0 and (not chk[1][i]):
				s1 += 'a'
			elif i == 1 and (not chk[1][i]):
				s1 += 'A'
			elif i == 2 and (not chk[1][i]):
				s1 += '1'
		for i in range(len(s) - len(s1) + 1):
			t = s[:i] + s1 + s[i + len(s1):]
			if check(t)[0]:
				print(t)
				break