Chef changed the password of his laptop a few days ago, but he can't remember it today. Luckily, he wrote the encrypted password on a piece of paper, along with the rules for decryption.
The encrypted password is a string S consists of ASCII printable characters except space (ASCII 33 - 126, in decimal notation, the same below). Read here for more details: ASCII printable characters.
Each rule contains a pair of characters ci, pi, denoting that every character ci appears in the encrypted password should be replaced with pi. Notice that it is not allowed to do multiple replacements on a single position, see example case 1 for clarification.
After all the character replacements, the string is guaranteed to be a positive decimal number. The shortest notation of this number is the real password. To get the shortest notation, we should delete all the unnecessary leading and trailing zeros. If the number contains only non-zero fractional part, the integral part should be omitted (the shortest notation of "0.5" is ".5"). If the number contains zero fractional part, the decimal point should be omitted as well (the shortest notation of "5.00" is "5").
Please help Chef to find the real password.

-----Input-----
The first line of the input contains an interger T denoting the number of test cases.
The description of T test cases follows.
The first line of each test case contains a single interger N, denoting the number of rules.
Each of the next N lines contains two space-separated characters ci and pi,
denoting a rule.
The next line contains a string S, denoting the encrypted password.

-----Output-----
For each test case, output a single line containing the real password.

-----Constraints-----
- 1 ≤ T ≤ 1000
- 0 ≤ N ≤ 94
- All characters in S and ci may be any ASCII printable character except space. (ASCII 33 - 126)
- All ci in a single test case are distinct.
- pi is a digit ("0" - "9") or a decimal point "." (ASCII 46).
- The total length of S in a single input file will not exceed 106.

-----Example-----
Input:
4
2
5 3
3 1
5
0
01800.00
0
0.00100
3
x 0
d 3
# .
0xd21#dd098x

Output:
3
1800
.001
321.33098

Difficulty: MEDIUM_HARD

Solutions:
import sys
for t in range(int(input())):
	m = {}
	for i in range(int(input())):
		(ci, pi) = input().split()
		m[ci] = pi
	s = input()
	ans = ''
	for i in range(len(s)):
		try:
			ans += m[s[i]]
		except:
			ans += s[i]
	dots = ans.count('.')
	if dots > 1:
		exit(1)
	if dots == 0:
		ans = ans.lstrip('0')
		if len(ans) == 0:
			print('0')
		else:
			print(ans)
	else:
		ans = ans.strip('0')
		size = len(ans)
		if size == 1:
			print('0')
			continue
		if ans[size - 1] == '.':
			ans = ans[:size - 1]
		print(ans)


for test in range(int(input())):
	N = int(input())
	rules = {}
	for i in range(N):
		cp = input().split()
		rules[cp[0]] = cp[1]
	encryption = input()
	passwd = ''
	for i in encryption:
		if rules.get(i):
			passwd += rules[i]
		else:
			passwd += i
	passwd = passwd.lstrip('0')
	if passwd.find('.') != -1:
		passwd = passwd.rstrip('0')
	try:
		if passwd[-1] == '.':
			passwd = passwd[:-1]
			if passwd == '':
				print(0)
			else:
				print(passwd)
		else:
			print(passwd)
	except:
		print(0)


from decimal import Decimal
T = int(input())
for _ in range(T):
	N = int(input())
	data = dict()
	for __ in range(N):
		(ci, pi) = input().split()
		data[ci] = pi
	S = list(input())
	for i in range(len(S)):
		if S[i] in data.keys():
			S[i] = data[S[i]]
	S = ''.join(S)
	if '.' in S:
		S = S.strip('0').rstrip('.')
	else:
		S = S.lstrip('0')
	print(S or '0')


t = int(input())
for ttt in range(t):
	n = int(input())
	rules = {}
	for i in range(n):
		q = input().split(' ')
		a = q[0]
		b = q[1]
		rules[a] = b
	s0 = input()
	s1 = ''
	for i in s0:
		if i in rules.keys():
			s1 += rules[i]
		else:
			s1 += i
	if all((x == '0' or x == '.' for x in s1)):
		print('0')
	else:
		czy = '.' in s1
		p = 0
		while s1[p] == '0':
			p += 1
		k = len(s1) - 1
		while czy and s1[k] == '0':
			k -= 1
		if s1[k] == '.':
			k -= 1
		print(s1[p:k + 1])


for _ in range(int(input())):
	d = {}
	for __ in range(int(input())):
		(c, p) = map(str, input().split())
		d[c] = p
	s = input()
	k = ''
	for i in range(0, len(s)):
		if s[i] in d.keys():
			k = k + d[s[i]]
		else:
			k = k + s[i]
	if '.' in k:
		k = k.strip('0').rstrip('.')
	else:
		k = k.lstrip('0')
	print(k or '0')


for __ in range(int(input())):
	rules = dict()
	for _ in range(int(input())):
		(c, p) = (x for x in input().split())
		rules[c] = p
	orig_s = input()
	new_s = ''
	for i in orig_s:
		new_s += rules.get(i, i)
	new_s = new_s.lstrip('0')
	if '.' in new_s:
		new_s = new_s.rstrip('0').rstrip('.')
	print(new_s if new_s != '' else '0')


t = int(input())
for tti in range(t):
	n = int(input())
	X = {}
	for i in range(n):
		(a, b) = list(input().split(' '))
		X[a] = b
	w = input()
	x = ''
	for i in range(len(w)):
		if w[i] in X.keys():
			x += X[w[i]]
		else:
			x += w[i]
	if len(x.split('.')) == 1:
		ii = 0
		while ii < len(x) and x[ii] == '0':
			ii += 1
		if x[ii:] != '':
			print(x[ii:])
		else:
			print(0)
	else:
		ii = 0
		while ii < len(x) and x[ii] == '0':
			ii += 1
		jj = len(x) - 1
		while jj > 0 and x[jj] == '0':
			jj -= 1
		if x[jj] == '.':
			jj -= 1
		if x[ii:jj + 1] != '':
			print(x[ii:jj + 1])
		else:
			print(0)


try:
	from debug import debug, timer
except ImportError:
	pass
from sys import stdin
input = stdin.readline

def rii():
	return range(int(input().strip()))

def ii():
	return int(input().strip())

def mii():
	return map(int, input().strip().split(' '))

def lmii():
	return list(map(int, input().strip().split(' ')))

def si():
	return str(input().strip())

def getvals():
	while True:
		yield from input().split()

def tri(n):
	return n * (n + 1) // 2

def smallest_first(m, n):
	return (min(m, n), max(m, n))

def solve(*args):
	(n, d, s) = args
	outp = ''.join([d[x] if x in d else x for x in s])
	outp = outp.lstrip('0')
	if '.' in outp:
		outp = outp.rstrip('0')
		outp = outp.rstrip('.')
	if outp == '':
		return 0
	return outp

def do_codechef():
	for t in rii():
		n = ii()
		d = {a: b for (a, b) in (si().split(' ') for _ in range(n))}
		s = si()
		print(solve(n, d, s))
do_codechef()
exit()


def find_password():
	password = ''
	for char in S:
		if char in C:
			i = C.index(char)
			password += P[i]
		else:
			password += char
	password = password.lstrip('0')
	if '.' in password:
		password = password.rstrip('0')
		password = password.rstrip('.')
	if not password:
		password = '0'
	print(password)
T = int(input())
for _ in range(T):
	N = int(input())
	C = []
	P = []
	for _ in range(N):
		(c, p) = input().split()
		C.append(c)
		P.append(p)
	S = input()
	find_password()


for _ in range(int(input())):
	n = int(input())
	rep = {}
	for i in range(n):
		(c, p) = input().split()
		rep[c] = p
	s = input()
	new = ''
	bl = False
	for i in s:
		if i in rep:
			new += rep[i]
		else:
			new += i
		if new[-1] == '.':
			bl = True
	start = -1
	for i in new:
		if i == '0':
			start += 1
		else:
			break
	if start > -1:
		new = new[start + 1:]
	end = len(new)
	if bl:
		for i in new[::-1]:
			if i == '0':
				end -= 1
			elif i == '.':
				end -= 1
				break
			else:
				break
	if new[:end] == '':
		print(0)
	else:
		print(new[:end])


def releze(s):
	for i in range(len(s)):
		if s[i] != '0':
			break
	s = s[i:]
	return s

def retrze(s):
	for i in range(len(s) - 1, -1, -1):
		if s[i] != '0':
			break
	s = s[:i + 1]
	return s
t = int(input())
for a0 in range(t):
	n = int(input())
	a1 = []
	a2 = []
	for a4 in range(n):
		t = input().strip().split(' ')
		a1.append(t[0])
		a2.append(t[1])
	s = input()
	ds = {}
	sa = []
	fsa = []
	for i in range(len(s)):
		sa.append(s[i])
		fsa.append(' ')
		if s[i] in ds:
			ds[s[i]].append(i)
		else:
			ds[s[i]] = [i]
	for i in range(len(a1)):
		if a1[i] in ds:
			for j in ds[a1[i]]:
				fsa[j] = a2[i]
			ds.pop(a1[i], None)
	for i in ds:
		for j in ds[i]:
			fsa[j] = i
	s = releze(''.join(fsa))
	if '.' in s:
		s = retrze(s)
	if s[-1] == '.':
		s = s[:-1]
	if len(s) == 0:
		print('0')
	else:
		print(s)