Utkarsh is currently sitting for placements. He has applied to three companies named A, B, and C.

You know Utkarsh's order of preference among these 3 companies, given to you as characters first, second, and third respectively (where first is the company he prefers most).

You also know that Utkarsh has received offers from exactly two of these three companies, given you as characters x and y.

Utkarsh will always accept the offer from whichever company is highest on his preference list. Which company will he join?

------ Input Format ------ 

- The first line of input contains a single integer T, denoting the number of test cases. The description of T test cases follows.
- The first line of each test case contains three different space-separated characters: first, second, and third, denoting Utkarsh's order of preference among the three companies.
- The second line of each test case contains two space-separated characters x and y, the companies from which Utkarsh has received offers.

------ Output Format ------ 

For each test case, print one line containing a single character, the company whose offer Utkarsh will accept.

The output is not case sensitive, so if the answer is A, both a and A will be accepted.

------ Constraints ------ 

$1 ≤ T ≤ 36$
- first, second and third are three different characters among $\{A, B, C\}$.
$x$ and $y$ are two different characters among $\{A, B, C\}$.

------ subtasks ------ 

Subtask #1 (100 points): Original constraints

----- Sample Input 1 ------ 
2
A B C
A B
B C A
A C
----- Sample Output 1 ------ 
A
C
----- explanation 1 ------ 
Test Case 1. Utkarsh has received offers from $A$ and $B$. Of these two, he prefers company $A$ (first preference) over $B$ (second preference). Therefore Utkarsh will accept the offer of company $A$.

Test Case 2. Utkarsh has received offers from $A$ and $C$, where company $C$ is his second preference and company $A$ is his third preference. Utkarsh will accept the offer of company $C$.

Difficulty: EASY

Solutions:
t = int(input())
for i in range(t):
	(f, s, t) = input().split()
	(x, y) = input().split()
	if f == x or f == y:
		print(f)
	elif s == x or s == y:
		print(s)
	else:
		print(t)


for i in range(int(input())):
	l1 = list(map(str, input().split()))
	l2 = list(map(str, input().split()))
	for i in l1:
		if i in l2:
			print(i)
			break


for i in range(int(input())):
	l1 = list(map(str, input().split()))
	l2 = list(map(str, input().split()))
	if l1[0] in l2:
		print(l1[0])
	elif l1[1] in l2:
		print(l1[1])
	elif l1[2] in l2:
		print(l1[2])
	else:
		break


for i in range(0, int(input())):
	x = list(input().split())
	y = list(input().split())
	a = x.index(y[0])
	b = x.index(y[1])
	if a < b:
		print(y[0])
	elif a > b:
		print(y[1])


for i in range(int(input())):
	p = list(map(str, input().split()))
	f = list(map(str, input().split()))
	for j in p:
		if j in f:
			print(j)
			break


for _ in range(int(input())):
	(a, b, c) = map(str, input().split())
	x = list(map(str, input().split()))
	if a in x:
		print(a)
	elif b in x:
		print(b)
	else:
		print(c)


t = int(input())
for i in range(t):
	pre = list(map(str, input().split()))
	(a, b) = map(str, input().split())
	for i in pre:
		if a == i:
			print(i)
			break
		elif b == i:
			print(i)
			break


t = int(input())
for i in range(t):
	pref = list(map(str, input().split()))
	placed = list(map(str, input().split()))
	for i in range(len(pref)):
		if pref[i] in placed:
			print(pref[i])
			break


n = int(input())
for i in range(n):
	m = input().split()
	m1 = input().split()
	first = m.index(m1[0])
	second = m.index(m1[1])
	if first < second:
		print(m1[0])
	else:
		print(m1[1])


t = int(input())
for i in range(t):
	(a, b, c) = map(str, input().split())
	(x, y) = map(str, input().split())
	if a == x or a == y:
		print(a)
	elif b == x or b == y:
		print(b)
	else:
		print(c)


t = int(input())
for i in range(t):
	a = input().split()
	(x, y) = map(str, input().split())
	for i in a:
		if x == i or y == i:
			print(i)
			break


t = int(input())
for i in range(t):
	l = list(map(str, input().split()))
	(d, e) = map(str, input().split())
	x = l.index(d)
	y = l.index(e)
	print(l[min(x, y)])


for i in range(int(input())):
	list1 = list(map(str, input().split()))
	list2 = list(map(str, input().split()))
	for i in range(len(list1)):
		if list1[i] in list2:
			print(list1[i])
			break


T = int(input())
for _ in range(T):
	lst1 = [i for i in input().split()][0:3]
	lst2 = [i for i in input().split()][0:2]
	idx = 4
	for e in lst2:
		idx_e = lst1.index(e)
		if idx_e < idx:
			idx = idx_e
	if idx == 4:
		print(-1)
	else:
		print(lst1[idx])


def code():
	cases = int(input())
	for _ in range(cases):
		comapnies = map(str, input().split(' '))
		offers = list(map(str, input().split(' ')))
		for c in comapnies:
			if c in offers:
				print(c)
				break
code()


for _ in range(int(input())):
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	for i in range(3):
		if a[i] in b:
			print(a[i])
			break


for i in range(int(input())):
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	for j in a:
		if j in b:
			print(j)
			break


t = int(input())
for i in range(t):
	x = list(map(str, input().split()))
	y = list(map(str, input().split()))
	for i in range(len(x)):
		if x[i] in y:
			print(x[i])
			break


T = int(input())
for i in range(T):
	(first, second, third) = map(str, input().split())
	(x, y) = map(str, input().split())
	if x == first and y == second:
		print(x)
	elif x == first and y == third:
		print(x)
	elif x == second and y == first:
		print(y)
	elif x == second and y == third:
		print(x)
	elif x == third and y == first:
		print(y)
	else:
		print(y)


t = int(input())
for i in range(t):
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	for i in range(len(a)):
		if a[i] in b:
			print(a[i])
			break


T = int(input())
for i in range(T):
	n = list(map(str, input().split()))
	n1 = list(map(str, input().split()))
	for i in range(len(n)):
		if n[i] in n1:
			print(n[i])
			break


t = int(input())
for i in range(t):
	l = []
	m1 = input().split()
	m2 = input().split()
	for x in m1:
		if x in m2:
			l.append(x)
	print(l[0])


for i in range(int(input())):
	(first, second, third) = map(str, input().split())
	(x, y) = map(str, input().split())
	list1 = [first, second, third]
	list2 = [x, y]
	for i in range(3):
		if list2[0] == list1[i]:
			o = i
		if list2[1] == list1[i]:
			p = i
	if p > o:
		print(list1[o])
	else:
		print(list1[p])


T = int(input())
for _ in range(T):
	com = list(map(str, input().split()))
	(x, y) = map(str, input().split())
	print(x) if com.index(x) < com.index(y) else print(y)


for i in range(int(input())):
	s = list(map(str, input().split()))
	x = list(map(str, input().split()))
	for i in range(len(s)):
		if s[i] in x:
			print(s[i])
			break


t = int(input())
for _ in range(t):
	(f1, f2, f3) = list(input().split())
	(x, y) = list(input().split())
	s = [x, y]
	temp = []
	for el in [f1, f2, f3]:
		if el in s:
			temp.append(el)
	if temp[0] == f1:
		print(f1)
	elif temp[0] == f2:
		print(f2)
	else:
		print(f3)


t = int(input())
for _ in range(t):
	(f1, f2, f3) = list(input().split())
	(x, y) = list(input().split())
	d = dict()
	d[f1] = 1
	d[f2] = 2
	d[f3] = 3
	s = [x, y]
	temp = []
	for el in [f1, f2, f3]:
		if el in s:
			temp.append(el)
	if temp[0] == f1:
		print(f1)
	elif temp[0] == f2:
		print(f2)
	else:
		print(f3)


for _ in range(int(input())):
	s = input()
	s1 = input()
	if s.index(s1[0]) > s.index(s1[2]):
		print(s1[2])
	else:
		print(s1[0])


for i in range(int(input())):
	order = list(input().split())
	chosen = list(input().split())
	if order.index(chosen[0]) < order.index(chosen[1]):
		print(chosen[0])
	else:
		print(chosen[1])


for i in range(int(input())):
	a = input()
	(x, y) = map(str, input().split())
	for i in a:
		if i == x or i == y:
			print(i)
			break
		else:
			continue


for _ in range(int(input())):
	n = list(map(str, input().split()))
	m = list(map(str, input().split()))
	for i in range(3):
		if n[i] in m:
			print(n[i])
			break


t = int(input())
for i in range(t):
	list_a = list(map(str, input().split()))
	list_b = list(map(str, input().split()))
	for i in range(len(list_a)):
		if list_a[i] in list_b:
			print(list_a[i])
			break


t = int(input())
while t:
	t -= 1
	p = list(map(str, input().split()))
	q = list(map(str, input().split()))
	for i in range(len(p)):
		if p[i] in q:
			print(p[i])
			break


for _ in range(int(input())):
	l1 = list(map(str, input().split()))
	l2 = list(map(str, input().split()))
	for j in range(len(l1)):
		if l1[j] in l2:
			print(l1[j])
			break


t = int(input())
for _ in range(t):
	arr = list(map(str, input().split()))
	arr2 = list(map(str, input().split()))
	for i in range(len(arr)):
		if arr[i] in arr2:
			print(arr[i])
			break


n = int(input())
for i in range(n):
	l = list(input().split())
	(x, y) = input().split()
	l1 = l2 = 0
	for i in range(3):
		if l[i] == x:
			l1 = i
		elif l[i] == y:
			l2 = i
	if l1 < l2:
		print(x)
	else:
		print(y)


class kishore:

	def first(self, t):
		for i in range(t):
			ar1 = list(map(str, input().split()))
			ar2 = list(map(str, input().split()))
			for i in range(len(ar1)):
				if ar1[i] in ar2:
					print(ar1[i])
					break
t = int(input())
o = kishore()
o.first(t)


for i in range(int(input())):
	companies = list(map(str, input().split()))
	offers = list(map(str, input().split()))
	for j in range(len(companies)):
		if companies[j] in offers:
			print(companies[j])
			break


for i in range(int(input())):
	l = list(map(str, input().split()))
	s = list(map(str, input().split()))
	for j in l:
		if j in s:
			print(j)
			break


t = int(input())
c = []
p = []
for i in range(t):
	c.append(input().split(' '))
	p.append(input().split(' '))
for i in range(len(c)):
	for j in c[i]:
		if j in p[i]:
			print(j)
			break


t = int(input())
for i in range(0, t):
	l = list(map(str, input().split(' ')))
	n = list(map(str, input().split(' ')))
	for i in range(0, len(l)):
		if l[i] in n:
			print(l[i])
			break


for i in range(int(input())):
	l = input().split()
	(x, y) = input().split()
	a = l.index(x)
	b = l.index(y)
	m = min(a, b)
	print(l[m])


for i in range(int(input())):
	(a, b, c) = map(str, input().split())
	(a1, b1) = map(str, input().split())
	if a == a1 or a == b1:
		print(a)
	else:
		print(b)


t = int(input())
for i in range(t):
	(a, b, c) = map(str, input().split())
	(d, e) = map(str, input().split())
	if a == d or a == e:
		print(a)
	else:
		print(b)


for _ in range(int(input())):
	arr = list(map(str, input().split()))
	(x, y) = map(str, input().split())
	if arr.index(x) > arr.index(y):
		print(y)
	else:
		print(x)


try:
	t = int(input())
	for r in range(t):
		(a, b, c) = map(str, input().split())
		(x, y) = map(str, input().split())
		if a == x:
			print(a)
		elif a == y:
			print(a)
		elif b == x:
			print(b)
		elif b == y:
			print(b)
		elif c == x:
			print(c)
		else:
			print(c)
except:
	pass


for i in range(int(input())):
	lis = list(map(str, input().split()))
	offer = list(map(str, input().split()))
	if lis.index(offer[0]) < lis.index(offer[1]):
		print(offer[0])
	else:
		print(offer[1])


c = int(input())
for i in range(c):
	(f, s, t) = map(str, input().split())
	(off1, off2) = map(str, input().split())
	if off1 == f or off2 == f:
		print(f)
	elif off1 == s or off2 == s:
		print(s)
	else:
		print(t)


T = int(input())
while T > 0:
	(p1, p2, p3) = map(str, input().split(' '))
	(c1, c2) = map(str, input().split(' '))
	if p1 == c1 or p1 == c2:
		print(p1)
	elif p2 == c1 or p2 == c2:
		print(p2)
	else:
		print(p3)
	T -= 1


for i in range(int(input())):
	(c1, c2, c3) = map(str, input().split(' '))
	(p1, p2) = map(str, input().split(' '))
	if p1 == c1 or p2 == c1:
		print(c1)
	elif p1 == c2 or p2 == c2:
		print(c2)
	elif p1 == c3 or p2 == c3:
		print(c3)


t = int(input())
for i in range(t):
	(x, y, z) = map(str, input().split())
	(n, m) = map(str, input().split())
	if n == x or m == x:
		print(x)
	elif n == y or m == y:
		print(y)
	else:
		print(z)


t = int(input())
for i in range(t):
	(x, y, z) = map(str, input().split())
	(p, q) = map(str, input().split())
	if p == x or q == x:
		print(x)
	elif p == y or q == y:
		print(y)
	else:
		print(z)


for i in range(int(input())):
	x = input().split()
	a = input().split()
	for i in x:
		if i not in a:
			x.remove(i)
	print(x[0])


t = int(input())
while t > 0:
	l = list(input().split())
	(x, y) = input().split()
	if l.index(x) < l.index(y):
		print(x)
	else:
		print(y)
	t = t - 1


T = int(input())
for i in range(T):
	(A, B, C) = input().split(' ')
	(x, y) = input().split(' ')
	L = [x, y]
	if A in L:
		print(A)
	elif B in L:
		print(B)
	else:
		print(C)