Once upon a time chef decided to learn encodings. And, obviously, he started with the easiest one (well, actually the easiest after Caesar cypher) – substitution cypher.
But very soon Chef got bored with encoding/decoding, so he started thinking how to hack this cypher.
He already knows some algorithm, which is not always correct,
but it’s sufficient for now. Here is its description.
Imagine we know frequency sequence of English letters (this means, that letters are sorted by their frequency of appearing in English texts, in ascending order).
And let’s find frequency sequence of cyphered letters (if some of them appear equal number of times, then first in frequency sequence will be lower letter between them).
Now, using this two frequency sequences we can recover plain text. Just substitute cyphered letter with origin one, if they are at same positions in sequences. 
Now, Chef has frequency sequence of English letters and cypher text. And he asks you to recover plain text. Please, help him.


Input
In first line number T is given - number of test cases. Then T test cases follow. Each test case consists of two lines - frequency sequence and encrypted text.

Output
For each test case you should output decrypted with the given frequency sequence text. Please note, that the case of letters should be preserved. 

Constraints

 1 ≤ T ≤ 1000; 
 Length of frequency sequence is always 26; 
 1 ≤ length of the text ≤ 150000; 
 1 ≤ sum lengths of all texts ≤ 150000. 
 Frequency sequence consists of all lowercase English letters. Text consists of any characters. 


Example

Input:
3
qwrtyuipasdfgjkzxcvbnmheol
dummy!
bfgjklmopqrstuwxzhvnicdyea
abcd b efgd hbi!
qwrtyuipasdfgjkzxcvbnmheol
Dummy!

Output:
hello!
have a nice day!
Hello!
def cmp(tup):
	return (tup[1], tup[0])



def get_decoder(text,freqseq):
	mymap = {}
	for ch in text:
		if ch.isalpha():
			if ch.lower() in mymap:
				mymap[ch.lower()] += 1
			else:
				mymap[ch.lower()] = 1

	v = []
	for k in mymap:
		v.append((k,mymap[k]))

	v = sorted(v,key=cmp)

	length = len(v)
	lastcut = freqseq[-length:]

	decoder = {}
	for i in range(length):
		decoder[v[i][0]] = lastcut[i]


	return decoder


t = input()
while t:
	freqseq = raw_input()
	text = raw_input()

	#decoder = {}
	decoder = get_decoder(text,freqseq)

	ans = list(text)
	for i in range(len(ans)):
		if ans[i].isalpha():
			if ans[i].isupper():
				ans[i] = decoder[ans[i].lower()].upper()
			else:
				ans[i] = decoder[ans[i]]

	ans = ''.join(ans)

	print ans

	t = t-1