Read problems statements in mandarin chinese, russian and vietnamese as well. 

Today is the final round of La Liga, the most popular professional football league in the world. Real Madrid is playing against Malaga and Barcelona is playing against Eibar. These two matches will decide who wins the league title. Real Madrid is already 3 points ahead of Barcelona in the league standings. In fact, Real Madrid will win the league title, except for one scenario: If Real Madrid loses against Malaga, and Barcelona wins against Eibar, then the La Liga title will go to Barcelona. In any other combination of results, Real Madrid will win the title.

You will be given multiple scenarios for these two games, where in each one you will be given the number of goals each team scored in their respective match. A team wins a match if it scores more than the opponent. In case they score the same number of goals, it's a draw. Otherwise, the team loses the game. You are asked to tell the winner of the La Liga title in each scenario.

------ Input ------ 

The first line contains a single number T, the number of scenarios.
Each scenario is described by four lines. Each line starts with a team name followed by the number of goals this team scored in its corresponding match. (Barcelona plays Eibar and Real Madrid plays Malaga). The names are given in any arbitrary order within a scenario.

------ Output ------ 

For each scenario, output a single line showing the title winner in case this scenario happens. It should be either "RealMadrid" or "Barcelona".

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

$1 ≤ T ≤ 500$
$0 ≤ number of goals scored by a team in a match ≤ 20$

----- Sample Input 1 ------ 
2
Barcelona 2
Malaga 1
RealMadrid 1
Eibar 0
Malaga 3
RealMadrid 2
Barcelona 8
Eibar 6
----- Sample Output 1 ------ 
RealMadrid
Barcelona

Difficulty: EASY

Solutions:
T = int(input())
for i in range(T):
	scores = dict()
	for j in range(4):
		(team, score) = map(str, input().split(' '))
		score = int(score)
		scores[team] = score
	if scores['RealMadrid'] < scores['Malaga'] and scores['Barcelona'] > scores['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


T = int(input())
for i in range(T):
	(Team1, score1) = map(str, input().split())
	(Team2, score2) = map(str, input().split())
	(Team3, score3) = map(str, input().split())
	(Team4, score4) = map(str, input().split())
	if Team1 == 'RealMadrid' and int(score2) > int(score1):
		if Team3 == 'Barcelona' and int(score3) > int(score4):
			print('Barcelona')
		elif Team4 == 'Barcelona' and int(score4) > int(score3):
			print('Barcelona')
		else:
			print('RealMadrid')
	elif Team2 == 'RealMadrid' and int(score1) > int(score2):
		if Team3 == 'Barcelona' and int(score3) > int(score4):
			print('Barcelona')
		elif Team4 == 'Barcelona' and int(score4) > int(score3):
			print('Barcelona')
		else:
			print('RealMadrid')
	elif Team3 == 'RealMadrid' and int(score4) > int(score3):
		if Team1 == 'Barcelona' and int(score1) > int(score2):
			print('Barcelona')
		elif Team2 == 'Barcelona' and int(score2) > int(score1):
			print('Barcelona')
		else:
			print('RealMadrid')
	elif Team4 == 'RealMadrid' and int(score3) > int(score4):
		if Team1 == 'Barcelona' and int(score1) > int(score2):
			print('Barcelona')
		elif Team2 == 'Barcelona' and int(score2) > int(score1):
			print('Barcelona')
		else:
			print('RealMadrid')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	d = {}
	for j in range(4):
		(n, s) = map(str, input().split())
		d[n] = int(s)
	if d['RealMadrid'] < d['Malaga'] and d['Barcelona'] > d['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	d = {}
	for k in range(4):
		(a, a1) = input().split()
		d[a] = int(a1)
	rm = 0
	for key in d:
		if key == 'RealMadrid':
			rm = rm + d[key]
		if key == 'Barcelona':
			b = d[key]
		if key == 'Eibar':
			e = d[key]
		if key == 'Malaga':
			m = d[key]
	if (b > e) & (rm < m):
		print('Barcelona')
	else:
		print('RealMadrid')


for _ in range(int(input())):
	e = 0
	b = 0
	r = 0
	m = 0
	for i in range(4):
		dic = input().split(' ')
		if 'Eibar' in dic:
			e = int(dic[1])
		elif 'Barcelona' in dic:
			b = int(dic[1])
		elif 'Malaga' in dic:
			m = int(dic[1])
		else:
			r = int(dic[1])
	if b > e and r < m:
		print('Barcelona')
	else:
		print('RealMadrid')


for i in range(int(input())):
	s = {}
	a = input().split()
	b = input().split()
	c = input().split()
	d = input().split()
	s[a[0]] = int(a[1])
	s[b[0]] = int(b[1])
	s[c[0]] = int(c[1])
	s[d[0]] = int(d[1])
	bar = s['Barcelona']
	mal = s['Malaga']
	rel = s['RealMadrid']
	ei = s['Eibar']
	if bar > ei and rel < mal:
		print('Barcelona')
	else:
		print('RealMadrid')


for i in range(int(input())):
	l = []
	for j in range(4):
		t = input().split()
		l.append(t)
	l.sort()
	if int(l[0][1]) > int(l[1][1]) and int(l[2][1]) > int(l[3][1]):
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	a = {}
	for j in range(4):
		(teams, scores) = map(str, input().split(' '))
		scores = int(scores)
		a[teams] = scores
	if a['Barcelona'] > a['Eibar'] and a['RealMadrid'] < a['Malaga']:
		print('Barcelona')
	else:
		print('RealMadrid')


T = int(input())
for _ in range(T):
	scores = dict()
	for _ in range(4):
		(team, score) = input().split()
		scores[team] = int(score)
	if scores['RealMadrid'] < scores['Malaga'] and scores['Barcelona'] > scores['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	b = 0
	m = 0
	r = 0
	e = 0
	for i in range(4):
		line = input().split(' ')
		if 'Barcelona' in line:
			b = line[1]
		if 'Malaga' in line:
			m = line[1]
		if 'RealMadrid' in line:
			r = line[1]
		if 'Eibar' in line:
			e = line[1]
	if m > r and b > e:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	s = dict()
	for j in range(4):
		(t, sc) = map(str, input().split())
		sc = int(sc)
		s[t] = sc
	if s['RealMadrid'] < s['Malaga'] and s['Barcelona'] > s['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for _ in range(t):
	scores = {}
	for __ in range(4):
		(team, score) = input().split()
		scores[team] = int(score)
	if scores['Barcelona'] > scores['Eibar'] and scores['RealMadrid'] < scores['Malaga']:
		print('Barcelona')
	else:
		print('RealMadrid')


for _ in range(int(input())):
	arr = {}
	for _ in range(4):
		(a, b) = input().split()
		arr[a] = b
	if arr['Barcelona'] > arr['Eibar'] and arr['RealMadrid'] < arr['Malaga']:
		print('Barcelona')
	else:
		print('RealMadrid')


for i in range(int(input())):
	d = dict()
	for j in range(4):
		(s, n) = input().split()
		d[s] = int(n)
	if d.get('RealMadrid') < d.get('Malaga') and d.get('Barcelona') > d.get('Eibar'):
		print('Barcelona')
	else:
		print('RealMadrid')


T = int(input())
for i in range(T):
	E = 0
	B = 0
	R = 0
	M = 0
	for j in range(4):
		dic = input().split(' ')
		if 'Eibar' in dic:
			E = int(dic[1])
		elif 'Barcelona' in dic:
			B = int(dic[1])
		elif 'Malaga' in dic:
			M = int(dic[1])
		else:
			R = int(dic[1])
	if B > E and R < M:
		print('Barcelona')
	else:
		print('RealMadrid')


l = []
for i in range(1, int(input()) * 4 + 1):
	(name, sc) = input().split()
	l.append([name, sc])
	if i % 4 == 0:
		l.sort()
		if l[0][1] > l[1][1] and l[2][1] > l[3][1]:
			print(l[0][0])
		else:
			print(l[3][0])
		l = []


sc = []
club_list = []
for t in range(int(input())):
	for i in range(4):
		c = input()
		club_list.append(c)
	club_list.sort()
	for cl in club_list:
		sc.append(int(cl[-1]))
	if sc[0] > sc[1] and sc[2] > sc[3]:
		print('Barcelona')
	else:
		print('RealMadrid')
	club_list.clear()
	sc.clear()


for i in range(int(input())):
	scorecard = {}
	for me in range(4):
		(a, b) = map(str, input().split(' '))
		scorecard[a] = int(b)
	if scorecard['RealMadrid'] < scorecard['Malaga'] and scorecard['Barcelona'] > scorecard['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
while t:
	team1 = input()
	team2 = input()
	team3 = input()
	team4 = input()
	team_scores = {}
	team_scores[team1.split()[0]] = int(team1.split()[1])
	team_scores[team2.split()[0]] = int(team2.split()[1])
	team_scores[team3.split()[0]] = int(team3.split()[1])
	team_scores[team4.split()[0]] = int(team4.split()[1])
	if team_scores['RealMadrid'] < team_scores['Malaga'] and team_scores['Barcelona'] > team_scores['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')
	t -= 1


for _ in range(int(input())):
	di = {}
	a = input().split()
	b = input().split()
	c = input().split()
	d = input().split()
	di[a[0]] = a[1]
	di[b[0]] = b[1]
	di[c[0]] = c[1]
	di[d[0]] = d[1]
	if di['Barcelona'] > di['Eibar'] and di['RealMadrid'] < di['Malaga']:
		print('Barcelona')
	else:
		print('RealMadrid')


for i in range(int(input())):
	a = list(map(str, input().split()))
	b = list(map(str, input().split()))
	c = list(map(str, input().split()))
	d = list(map(str, input().split()))
	lis = [a, b, c, d]
	for (name, goal) in lis:
		if name == 'Barcelona':
			barca = int(goal)
		elif name == 'Malaga':
			malaga = int(goal)
		elif name == 'Eibar':
			eibar = int(goal)
		else:
			real = int(goal)
	print('Barcelona' if real < malaga and barca > eibar else 'RealMadrid')


t = int(input())
for i in range(t):
	di = dict()
	for i in range(4):
		(a, b) = input().split()
		di[a] = b
	if di['RealMadrid'] < di['Malaga'] and di['Barcelona'] > di['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


for case in range(int(input())):
	ss = {}
	for i in range(4):
		(t, s) = map(str, input().split())
		ss[t] = int(s)
	if ss['RealMadrid'] < ss['Malaga'] and ss['Barcelona'] > ss['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


for i in range(int(input())):
	a = dict()
	for j in range(4):
		(b, c) = map(str, input().split())
		c = int(c)
		a[b] = c
	if a['Barcelona'] > a['Eibar'] and a['RealMadrid'] < a['Malaga']:
		print('Barcelona')
	else:
		print('RealMadrid')


for test_case in range(int(input())):
	res = dict()
	for inp in range(4):
		(team, score) = map(str, input().split(' '))
		score = int(score)
		res[team] = score
	if res['RealMadrid'] < res['Malaga'] and res['Barcelona'] > res['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for _ in range(t):
	diction = {}
	for i in range(4):
		(name, score) = input().split()
		diction[name] = int(score)
	if diction['RealMadrid'] < diction['Malaga'] and diction['Barcelona'] > diction['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


T = int(input())
while T > 0:
	i = 1
	dict = {}
	while i <= 4:
		(t, s) = map(str, input().split())
		dict[t] = s
		s = int(s)
		i += 1
	if dict['RealMadrid'] < dict['Malaga'] and dict['Barcelona'] > dict['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')
	T -= 1


for _ in range(int(input())):
	(b, m, r, e) = (0, 0, 0, 0)
	for i in range(4):
		l = list(map(str, input().split()))
		if l[0] == 'Barcelona':
			b += int(l[1])
		elif l[0] == 'Malaga':
			m += int(l[1])
		elif l[0] == 'RealMadrid':
			r += int(l[1])
		else:
			e += int(l[1])
	if r < m and b > e:
		print('Barcelona')
	else:
		print('RealMadrid')


WIN_POINTS = 3
DRAW_POINTS = 1
LOSS_POINTS = 0
num_scenarios = int(input())
for i in range(num_scenarios):
	real_madrid_points = 3
	goals = {}
	for j in range(4):
		(team, team_goals) = input().split()
		goals[team] = int(team_goals)
	real_madrid_goals = goals.get('RealMadrid', 0)
	malaga_goals = goals.get('Malaga', 0)
	barcelona_goals = goals.get('Barcelona', 0)
	eibar_goals = goals.get('Eibar', 0)
	if not (0 <= real_madrid_goals <= 20 and 0 <= malaga_goals <= 20 and (0 <= barcelona_goals <= 20) and (0 <= eibar_goals <= 20)):
		print('Invalid input for scenario', i + 1)
		continue
	if real_madrid_goals > malaga_goals:
		real_madrid_points += WIN_POINTS
	elif real_madrid_goals == malaga_goals:
		real_madrid_points += DRAW_POINTS
	barcelona_points = 0
	if barcelona_goals > eibar_goals:
		barcelona_points += WIN_POINTS
	elif barcelona_goals == eibar_goals:
		barcelona_points += DRAW_POINTS
	else:
		barcelona_points += LOSS_POINTS
	if real_madrid_points > barcelona_points:
		print('RealMadrid')
	else:
		print('Barcelona')


t = int(input())
for i in range(0, t):
	d = dict()
	for _ in range(0, 4):
		(name, goals) = input().split()
		d[name] = goals
	if d['RealMadrid'] < d['Malaga'] and d['Barcelona'] > d['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for _ in range(t):
	(a, b) = str(input()).split()
	(c, d) = str(input()).split()
	(e, f) = str(input()).split()
	(g, h) = str(input()).split()
	list1 = [a, b, c, d, e, f, g, h]
	Barcelona = 0
	Malaga = 0
	RealMadrid = 0
	Eibar = 0
	for j in range(7):
		if list1[j] == 'Barcelona':
			Barcelona += int(list1[j + 1])
		elif list1[j] == 'Malaga':
			Malaga += int(list1[j + 1])
		elif list1[j] == 'RealMadrid':
			RealMadrid += int(list1[j + 1])
		elif list1[j] == 'Eibar':
			Eibar += int(list1[j + 1])
		else:
			pass
	if RealMadrid >= Malaga:
		print('RealMadrid')
	elif Barcelona > Eibar:
		print('Barcelona')
	else:
		print('RealMadrid')


for i in range(int(input())):
	(q, b, c, d) = (0, 0, 0, 0)
	for j in range(4):
		(a, o) = map(str, input().split())
		o = int(o)
		if a == 'Malaga':
			q = o
		elif a == 'RealMadrid':
			b = o
		elif a == 'Eibar':
			c = o
		else:
			d = o
	if b < q and d > c:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for _ in range(t):
	team_b = 0
	team_r = 0
	team_e = 0
	team_m = 0
	for i in range(4):
		(team, score) = map(str, input().split())
		if team == 'Barcelona':
			team_b = int(score)
		elif team == 'Malaga':
			team_m = int(score)
		elif team == 'RealMadrid':
			team_r = int(score)
		else:
			team_e = int(score)
	if team_r < team_m and team_b > team_e:
		print('Barcelona')
	else:
		print('RealMadrid')


for _ in range(int(input())):
	scores = {}
	for i in range(4):
		(team, score) = map(str, input().split(' '))
		score = int(score)
		scores[team] = score
	if scores['RealMadrid'] < scores['Malaga'] and scores['Barcelona'] > scores['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for tc in range(t):
	a = input()
	b = input()
	c = input()
	d = input()
	l = [a, b, c, d]
	l.sort()
	x = l[0][-1]
	y = l[1][-1]
	z = l[2][-1]
	k = l[3][-1]
	if x > y and k < z:
		print('Barcelona')
	else:
		print('RealMadrid')


for _ in range(int(input())):
	ab = dict()
	for j in range(4):
		(a, b) = map(str, input().split())
		b = int(b)
		ab[a] = b
	if ab['RealMadrid'] < ab['Malaga'] and ab['Barcelona'] > ab['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


for t in range(int(input())):
	score = {}
	for _ in range(4):
		(a, b) = map(str, input().split())
		score.update({a: int(b)})
	if score.get('RealMadrid') < score.get('Malaga') and score.get('Barcelona') > score.get('Eibar'):
		print('Barcelona')
	else:
		print('RealMadrid')


for t in range(int(input())):
	scores = dict()
	for i in range(4):
		(a, b) = map(str, input().split())
		b = int(b)
		scores[a] = b
	if scores['RealMadrid'] < scores['Malaga'] and scores['Barcelona'] > scores['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	teams = []
	points = []
	for i in range(4):
		s = input()
		points.append(int(s[len(s) - 1]))
		m = ''
		for j in range(0, len(s) - 1):
			m += s[j]
		teams.append(m)
	a = True
	b = False
	if points[teams.index('Barcelona ')] > points[teams.index('Eibar ')]:
		b = True
	if points[teams.index('RealMadrid ')] < points[teams.index('Malaga ')]:
		a = False
	if a == False:
		if b == True:
			print('Barcelona')
		else:
			print('RealMadrid')
	else:
		print('RealMadrid')


for i in range(int(input())):
	a = {}
	for j in range(4):
		b = input().split()
		a[b[0]] = int(b[1])
	if a['RealMadrid'] < a['Malaga'] and a['Barcelona'] > a['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')


for _ in range(int(input())):
	d = {}
	for i in range(4):
		s = input()
		l1 = s.split()
		d[l1[0]] = l1[1]
	if d['Barcelona'] > d['Eibar'] and d['RealMadrid'] < d['Malaga']:
		print('Barcelona')
	else:
		print('RealMadrid')


d = {}
for _ in range(int(input())):
	for i in range(4):
		(a, b) = map(str, input().split())
		d[a] = b
	if int(d['Barcelona']) > int(d['Eibar']) and int(d['RealMadrid']) < int(d['Malaga']):
		print('Barcelona')
	else:
		print('RealMadrid')


t = int(input())
for i in range(t):
	d = {}
	for m in range(4):
		line = input()
		(key, value) = line.split()
		d.update({key: value})
	if int(d['RealMadrid']) < int(d['Malaga']) and int(d['Barcelona']) > int(d['Eibar']):
		print('Barcelona')
	else:
		print('RealMadrid')


n = int(input())
l = []
for i in range(n):
	d = {}
	for i in range(4):
		(x, y) = map(str, input().split())
		d[x] = int(y)
	if d['RealMadrid'] < d['Malaga'] and d['Barcelona'] > d['Eibar']:
		l.append('Barcelona')
	else:
		l.append('RealMadrid')
for i in range(n):
	print(l[i])


for _ in range(int(input())):
	score_dict = {}
	for i in range(4):
		(team, score) = input().split()
		score = int(score)
		score_dict[team] = score
	if score_dict['RealMadrid'] < score_dict['Malaga'] and score_dict['Eibar'] < score_dict['Barcelona']:
		print('Barcelona')
	else:
		print('RealMadrid')


x = int(input())
for o in range(x):
	scores = dict()
	for j in range(4):
		(team, score) = map(str, input().split(' '))
		score = int(score)
		scores[team] = score
	if scores['RealMadrid'] < scores['Malaga'] and scores['Barcelona'] > scores['Eibar']:
		print('Barcelona')
	else:
		print('RealMadrid')