from functools import reduce

inf = open("bet.in", "r")
ouf = open("bet.out", "w")

colors = ["RED", "GREEN", "BLUE"]

t = int(inf.readline())
for x in range(t):
	A, C = map(int, inf.readline().split())
	d = [int(x) for x in inf.readline().split()]
	best = 0
	for i in range(3):
		d[i] += 1
		score = A * reduce(lambda s, x: s + x * x, d, 0) + C * min(d)
		if score > best:
			best = score
			opt = colors[i]
		d[i] -= 1
	print(opt, file=ouf)

