On an $8 \times 8$ grid, some horizontal rows have been painted red, and some vertical columns have been painted blue, in some order. The stripes are drawn sequentially, one after the other. When the stripe is drawn, it repaints all the cells through which it passes.

Determine which color was used last.

The red stripe was painted after the blue one, so the answer is R.


-----Input-----

The first line of the input contains a single integer $t$ ($1 \leq t \leq 4000$) — the number of test cases. The description of test cases follows. There is an empty line before each test case.

Each test case consists of $8$ lines, each containing $8$ characters. Each of these characters is either 'R', 'B', or '.', denoting a red square, a blue square, and an unpainted square, respectively.

It is guaranteed that the given field is obtained from a colorless one by drawing horizontal red rows and vertical blue columns.

At least one stripe is painted.


-----Output-----

For each test case, output 'R' if a red stripe was painted last, and 'B' if a blue stripe was painted last (without quotes).


-----Examples-----

Input
4
....B...
....B...
....B...
RRRRRRRR
....B...
....B...
....B...
....B...
RRRRRRRB
B......B
B......B
B......B
B......B
B......B
B......B
RRRRRRRB
RRRRRRBB
.B.B..BB
RRRRRRBB
.B.B..BB
.B.B..BB
RRRRRRBB
.B.B..BB
.B.B..BB
........
........
........
RRRRRRRR
........
........
........
........
Output
R
B
B
R


-----Note-----

The first test case is pictured in the statement.

In the second test case, the first blue column is painted first, then the first and last red rows, and finally the last blue column. Since a blue stripe is painted last, the answer is B.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
import sys

def solution():
	row = '\n'
	while row == '\n':
		row = sys.stdin.readline()
	a = [row.strip()]
	for i in range(7):
		row = sys.stdin.readline().strip()
		a.append(row)
	for i in range(8):
		if a[i] == 'RRRRRRRR':
			print('R')
			return
	print('B')

def main():
	t = int(input())
	while t:
		solution()
		t -= 1
main()


from sys import stdin
n = int(input())
lines = stdin.read().split()
a = 0
for ele in range(n):
	for i in range(8):
		if lines[i + a].count('R') == 8:
			print('R')
			break
	else:
		print('B')
	a += 8


import sys
input = sys.stdin.readline

def inp():
	return int(input())

def inlt():
	return list(map(int, input().split()))

def insr():
	s = input()
	return list(s[:len(s) - 1])

def invr():
	return map(int, input().split())

def output_list(l):
	print(' '.join(list(map(str, l))))

class Node:

	def __init__(self, i, next):
		self.i = i
		self.next = next

	def __str__(self):
		return str(self.i)

def test_case():
	input()
	rows = [input() for _ in range(8)]
	for row in rows:
		if '.' not in row:
			if 'B' not in row:
				print('R')
				return
	print('B')
n_cases = inp()
for i in range(n_cases):
	test_case()


import sys
input = sys.stdin.readline
output = sys.stdout.write
T = int(input())
a = input().split()
for t in range(T):
	f = 'B'
	while len(a) == 0:
		a = input().split()
	for i in list(range(8)):
		if not 'B' in a[0]:
			f = 'R'
		a = input().split()
	output(f + '\n')


import sys
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import permutations, combinations
from functools import lru_cache
input = lambda : sys.stdin.readline().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
inf = 2 ** 63 - 1
mod = 10 ** 9 + 7
T = int(input())
for _ in range(T):
	input()
	blah = []
	flag = False
	for _ in range(8):
		row = input()
		if row == 'RRRRRRRR':
			flag = True
		blah.append(row)
	if flag:
		print('R')
	else:
		print('B')


import sys
from collections import Counter, defaultdict, OrderedDict, deque
from itertools import permutations, combinations
from functools import lru_cache
input = lambda : sys.stdin.readline().rstrip()
ii = lambda : int(input())
mi = lambda : map(int, input().split())
li = lambda : list(mi())
inf = 2 ** 63 - 1
mod = 10 ** 9 + 7

def solve():
	input()
	out = False
	for i in range(8):
		x = input()
		if x == 'RRRRRRRR':
			out = True
	return 'R' if out else 'B'
for _ in range(ii()):
	print(solve())


import sys
from heapq import heapify, heappush, heappop
from math import ceil, floor, sqrt, gcd
from collections import defaultdict, deque
input = lambda : sys.stdin.readline().rstrip('\r\n')

def int_arr():
	return list(map(int, input().split()))

def str_arr():
	return list(map(str, input().split()))

def get_str():
	return map(str, input().split())

def get_int():
	return map(int, input().split())

def lcm(a, b):
	return a * b // gcd(a, b)
mod = 1000000007

def solve():
	input()
	tmp = 'B'
	for i in range(8):
		s = input()
		if s == 'R' * 8:
			tmp = 'R'
	print(tmp)
T = 1
T = int(input())
while T:
	solve()
	T -= 1


def color():
	input()
	res = 'B'
	for i in range(8):
		s = input()
		if s == 'RRRRRRRR':
			res = 'R'
	return res
n = int(input())
res = []
for i in range(n):
	res.append(color())
for i in res:
	print(i)


import sys
for i in range(int(sys.stdin.readline())):
	ls = []
	buf = sys.stdin.readline()
	for j in range(8):
		ls.append(sys.stdin.readline().strip())
	f = False
	for j in range(8):
		if ls[j] == 'R' * 8:
			print('R')
			f = True
			break
	if f:
		continue
	for j in range(8):
		s = ls[0][j]
		for k in range(1, 8):
			if ls[k][j] != s:
				f = True
				break
		if f:
			f = False
			continue
		if s != 'B':
			f = False
			continue
		print(s)
		break


N = int(input())
h = []
for i in range(N):
	k = 1
	d = input()
	for i in range(8):
		d = input()
		if d == 'RRRRRRRR':
			k = 0
	if k == 1:
		h.append('B')
	else:
		h.append('R')
for t in h:
	print(t)


n = int(input())
lst_ans = []
for i in range(n):
	str_0 = input()
	str_1 = input()
	str_2 = input()
	str_3 = input()
	str_4 = input()
	str_5 = input()
	str_6 = input()
	str_7 = input()
	str_8 = input()
	if str_1 == 'RRRRRRRR' or str_2 == 'RRRRRRRR' or str_3 == 'RRRRRRRR' or (str_4 == 'RRRRRRRR') or (str_5 == 'RRRRRRRR') or (str_6 == 'RRRRRRRR') or (str_7 == 'RRRRRRRR') or (str_8 == 'RRRRRRRR'):
		lst_ans.append('R')
	else:
		lst_ans.append('B')
for t in lst_ans:
	print(t)


t = int(input())
ans1 = []
for _ in range(t):
	input()
	arr = []
	for _ in range(8):
		s = input()
		arr.append(s)
	ans = 'B'
	for s in arr:
		if s.count('R') == 8:
			ans = 'R'
			break
	ans1.append(ans)
for val in ans1:
	print(val)


for _ in range(int(input())):
	ar = []
	b____ = input()
	for i in range(8):
		w = input()
		ar.append(w)
	for i in ar:
		if i.count('R') == 8:
			print('R')
			break
	else:
		print('B')


n = int(input())
for Pythonic__Python in range(1):
	l = []
	r = 'RRRRRRRR'
	b = 'BBBBBBBB'
	rr = ''
	bb = ''
	for i in range(n):
		ll = []
		for j in range(9):
			ll.append(input())
		l.append(ll)
	for k in range(n):
		L = l[k][1:]
		if r in L:
			print('R')
		else:
			print('B')


(t, r, h, k) = (int(input()), [], [], 'B')
for _ in range(t):
	n = input()
	for i in range(8):
		h.append(input())
	for i in range(8):
		if h[i] == 'RRRRRRRR':
			k = 'R'
	r.append(k)
	(h, k) = ([], 'B')
print(*r, sep='\n')


for _ in range(int(input())):
	abc = input()
	x = [input() for n in range(8)]
	print('R' if 8 * 'R' in x else 'B')


import math
import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = str(input())
	r = False
	for j in range(8):
		l = str(input()).strip()
		if l == 'RRRRRRRR':
			r = True
	if r:
		print('R')
	else:
		print('B')


t = int(input())
outputs = []
for i in range(t):
	redRow = False
	for i in range(9):
		line = input()
		if line == 'RRRRRRRR':
			redRow = True
	if redRow == True:
		outputs.append('R')
	else:
		outputs.append('B')
for output in outputs:
	print(output)


t = int(input())
ans = []
while t:
	flag = True
	for i in range(9):
		x = input()
		if x != '' and x[0] == 'R' and ('B' not in x):
			flag = False
	if flag:
		ans.append('B')
	else:
		ans.append('R')
	t = t - 1
for i in ans:
	print(i)


t = int(input())
for i in range(t):
	ans = 'B'
	for j in range(9):
		if input() == 'R' * 8:
			ans = 'R'
	print(ans)


def solve():
	a = input()
	r = False
	i = 0
	while i < 8:
		row = input()
		if row == 'RRRRRRRR':
			r = True
		i += 1
	if r:
		print('R')
	else:
		print('B')
t = int(input())
while t > 0:
	solve()
	t -= 1


t = int(input())
l = []
for i in range(t):
	input()
	a = 'B'
	for i in range(8):
		if input() == 'RRRRRRRR':
			a = 'R'
	l.append(a)
print()
for i in l:
	print(i)


for _ in range(int(input())):
	c = 'B'
	for i in range(9):
		if input() == 'R' * 8:
			c = 'R'
	print(c)


def stripes():
	input()
	output = 'B'
	for _ in range(8):
		line = input()
		if line == 'RRRRRRRR':
			output = 'R'
	return output
outputs = []
for _ in range(int(input())):
	outputs.append(stripes())
for i in outputs:
	print(i)


a = int(input())
o = []
for i in range(a):
	q = []
	w = input()
	for j in range(8):
		q.append(input())
	o.append('R' if 'RRRRRRRR' in q else 'B')
print('\n'.join(o))


t = int(input())
n = []
for x in range(t):
	is_R = False
	j = input()
	l = []
	for y in range(8):
		m = input()
		if m == 'RRRRRRRR':
			is_R = True
	if is_R:
		n.append('R')
	else:
		n.append('B')
print()
for r in n:
	print(r)


import sys
input = sys.stdin.readline

def f():
	for i in range(8):
		origin = mapp[i][0]
		if origin != 'R':
			continue
		flag = True
		for j in range(8):
			if mapp[i][j] != origin:
				flag = False
				break
		if flag:
			return origin
	for j in range(8):
		origin = mapp[0][j]
		if origin != 'B':
			continue
		flag = True
		for i in range(8):
			if mapp[i][j] != origin:
				flag = False
				break
		if flag:
			return origin
t = int(input())
for _ in range(t):
	input()
	mapp = [input().rstrip() for _ in range(8)]
	print(f())


def letra_superior(quad):
	filaVacia = False
	rfila = True
	ultimaLetra = 'R'
	f = 0
	c = 0
	while 1:
		if rfila:
			fila = quad[f]
			for i in range(8):
				if fila[i] == 'B':
					c = i
					rfila = False
					ultimaLetra = 'B'
					continue
			if ultimaLetra == 'R':
				return ultimaLetra
		else:
			for i in range(8):
				if quad[i][c] == 'R':
					f = i
					rfila = True
					ultimaLetra = 'R'
					continue
			if ultimaLetra == 'B':
				return ultimaLetra
	return ultimaLetra
r = []
t = int(input())
for i in range(t):
	quad = []
	input()
	for i in range(8):
		quad.append(input())
	letra = letra_superior(quad)
	r.append(letra)
for i in r:
	print(i)


def solve(lines):
	for line in lines:
		for c in line:
			if c != 'R':
				break
		else:
			return 'R'
	return 'B'
outputs = []
t = int(input())
for _ in range(t):
	input()
	outputs.append(solve([input().strip() for _ in range(8)]))
for output in outputs:
	print(output)


t = int(input())
result = []
for i in range(t):
	flag = 0
	for j in range(9):
		if input() == 'RRRRRRRR' and flag == 0:
			result.append('R')
			flag = 1
	if flag == 0:
		result.append('B')
for i in result:
	print(i)


t = int(input())
for i in range(t):
	ans = 'B'
	for k in range(9):
		if input() == 'RRRRRRRR':
			ans = 'R'
	print(ans)


def f(*l):
	z = 0
	for i in l:
		if i[0] == 'R':
			if 'B' not in i:
				z = 1
				break
	if z == 0:
		print('B')
	else:
		print('R')
for t in range(int(input())):
	inp = input()
	inp1 = input()
	inp2 = input()
	inp3 = input()
	inp4 = input()
	inp5 = input()
	inp6 = input()
	inp7 = input()
	inp8 = input()
	f(inp1, inp2, inp3, inp4, inp5, inp6, inp7, inp8)


t = int(input())
for i in range(t):
	a = 'B'
	B = input()
	for j in range(0, 8):
		if input() == 'RRRRRRRR':
			a = 'R'
			continue
	print(a)


t = int(input())
while t:
	flag = 1
	for i in range(9):
		s = input()
		if s == 'RRRRRRRR':
			flag = 0
	if flag:
		print('B')
	else:
		print('R')
	t = t - 1


t = int(input())
for i in range(t):
	f = 0
	input()
	for j in range(8):
		a = input()
		if a == 'R' * 8:
			f = 1
	if f == 0:
		print('B')
	else:
		print('R')


for _ in range(int(input())):
	q = 'B'
	input()
	for j in range(0, 8):
		if input() == 'RRRRRRRR':
			q = 'R'
	print(q)


t = int(input())
for i in range(t):
	empty1 = input()
	l1 = input()
	l2 = input()
	l3 = input()
	l4 = input()
	l5 = input()
	l6 = input()
	l7 = input()
	l8 = input()
	flag = False
	for j in range(len(l1)):
		if l1[j] == 'B' and l2[j] == 'B' and (l3[j] == 'B') and (l4[j] == 'B') and (l5[j] == 'B') and (l6[j] == 'B') and (l7[j] == 'B') and (l8[j] == 'B'):
			flag = True
			break
	if flag:
		print('B')
	else:
		print('R')


for _ in range(int(input())):
	input()
	letter = '.'
	for _ in range(8):
		s = input()
		if s == 'RRRRRRRR':
			letter = 'R'
	if letter == 'R':
		print('R')
	else:
		print('B')


t = int(input())
for i in range(t):
	input()
	ans = False
	for j in range(8):
		lst = input()
		if lst.count('R') == 8:
			ans = True
	if ans:
		print('R')
	else:
		print('B')


for _ in range(int(input())):
	input()
	ans = 'B'
	for i in range(8):
		row = input()
		if row.find('B') == -1:
			ans = 'R'
	print(ans)


for i in range(int(input())):
	input()
	ans = 'B'
	for j in range(8):
		line = input()
		if 'R' in line and 'B' not in line:
			ans = 'R'
	print(ans)


def get_last_color(grid):
	ans = 'B'
	for row in grid:
		if row == 'R' * 8:
			ans = 'R'
	return ans

def main():
	t = int(input())
	for _ in range(t):
		input()
		grid = [input() for _ in range(8)]
		last_color = get_last_color(grid)
		print(last_color)
main()


t = int(input())
for z in range(t):
	m = 0
	for i in range(9):
		s = input()
		if s == 'RRRRRRRR':
			m += 1
	if m == 0:
		print('B')
	else:
		print('R')


def main():
	t = int(input())
	for _ in range(t):
		answ = 'B'
		for i in range(9):
			s = input()
			if s == 'RRRRRRRR':
				answ = 'R'
		print(answ)
main()


for _ in range(int(input())):
	arr = []
	count = 0
	for j in range(9):
		arr.append(input())
	for i in range(9):
		if arr[i] == 'RRRRRRRR':
			print('R')
			break
		else:
			count += 1
			continue
	if count == 9:
		print('B')


n = int(input())
ans = []
for i in range(n):
	input()
	m = [input() for _ in range(8)]
	for x in range(8):
		col = m[x][0]
		if col == 'R':
			for y in range(8):
				if m[x][y] != col:
					break
			else:
				ans.append(col)
				break
	else:
		for y in range(8):
			col = m[0][y]
			if col == 'B':
				for x in range(8):
					if m[x][y] != col:
						break
				else:
					ans.append(col)
					break
for an in ans:
	print(an)


t = int(input())
for test in range(t):
	found = False
	for i in range(9):
		line = input()
		if line == 'RRRRRRRR':
			found = True
	if found:
		print('R')
	else:
		print('B')


t = int(input())
for i in range(t):
	m = []
	for j in range(9):
		e = input()
		m.append(e)
	f = 0
	for j in m:
		if j == 'RRRRRRRR':
			f = 1
	if f == 1:
		print('R')
	else:
		print('B')


n = int(input())
for i in range(n):
	r = []
	_ = input()
	for w in range(8):
		w = input()
		r.append(w)
	x = 'B'
	for i in r:
		if i == 'RRRRRRRR':
			x = 'R'
			break
	print(x)


for _ in range(int(input())):
	a = input()
	a = []
	for _ in range(8):
		a.append(input())
	out = 'B'
	for i in a:
		if i == 'RRRRRRRR':
			out = 'R'
	print(out)


t = int(input())
for i in range(t):
	input()
	x = [input()[:8] for _ in range(8)]
	if 'RRRRRRRR' in x:
		print('R')
	else:
		print('B')


for _ in range(int(input())):
	a = [input() for i in range(9)]
	ans = ''
	for i in a:
		if 'B' in i and 'R' not in i:
			ans = 'B'
		elif 'R' in i and 'B' not in i:
			ans = 'R'
			break
		else:
			ans = 'B'
	print(ans)


for _ in range(int(input())):
	matrix = []
	for i in range(9):
		matrix.append(input())
	r = 0
	for i in matrix:
		if i == 'RRRRRRRR':
			r = 1
	if r == 1:
		print('R')
	else:
		print('B')


t = int(input())
for i in range(t):
	color = 'B'
	for j in range(9):
		l = input()
		if l:
			if l == 'RRRRRRRR':
				color = 'R'
		else:
			continue
	print(color)


t = int(input(''))
results = []
for i in range(t):
	blank = input('')
	flag = 'Blue'
	for i in range(8):
		line = input('')
		if line.count('R') == 8:
			flag = 'Red'
	if flag == 'Blue':
		results.append('B')
	else:
		results.append('R')
for i in range(t):
	print(results[i])


t = int(input())
for k in range(t):
	R_flag = False
	input()
	for m in range(8):
		line = input()
		if '.' not in line and 'B' not in line:
			R_flag = True
	if R_flag:
		print('R')
	else:
		print('B')


n = int(input())
for i in range(n):
	_ = input()
	ans = 'B'
	for j in range(8):
		s = input()
		if s.count('R') == 8:
			ans = 'R'
	print(ans)


s = []
for t in range(int(input())):
	r = 'RRRRRRRR'
	d = '........'
	input()
	for i in range(8):
		s.append(input())
	res = ''
	for i in s:
		if i == r:
			res = 'R'
	if res == '':
		res = 'B'
	print(res)
	s.clear()


def color(x):
	re = 0
	for n in range(8):
		row = x[n]
		if '.' in row or 'B' in row:
			continue
		else:
			print('R')
			re = 1
			break
	if not re:
		print('B')
t = int(input())
for i in range(t):
	x = []
	lines = 0
	while lines < 8:
		in_line = input()
		if '.' in in_line or 'R' in in_line or 'B' in in_line:
			x.append(in_line)
			lines += 1
	color(x)


t = int(input())
for _ in range(t):
	s = 'B'
	input()
	p = 'RRRRRRRR'
	for _ in range(8):
		ans = input()
		if ans == p:
			s = 'R'
	print(s)


t = int(input())
for k in range(t):
	horiz = []
	empty = input()
	for i in range(8):
		app_horiz = input()
		horiz.append(app_horiz)
	try:
		if horiz.index('RRRRRRRR') >= 0:
			print('R')
	except ValueError:
		print('B')


def fun1(l, start):
	for r in l:
		st = set(r)
		if len(st) == 1 and 'R' in st:
			return 'R'
	return 'B'
t = int(input())
res = []
for i in range(t):
	st = input()
	l = []
	for i in range(8):
		l1 = list(input())
		l.append(l1)
	res.append(fun1(l, 0))
for i in res:
	print(i)


n = input()
n = int(n)
x = []
for i in range(n):
	res = 'B'
	_ = input()
	for j in range(8):
		str = input()
		if str == len(str) * 'R':
			res = 'R'
	print(res)


t = int(input())
for _ in range(t):
	n = 8
	s = 'B'
	input()
	a = 'RRRRRRRR'
	for j in range(n):
		x = input()
		if x == a:
			s = 'R'
	print(s)


def checkWithTranspse(a):
	for i in range(8):
		b = ''
		for j in range(8):
			b += a[j][i]
		if b == 'BBBBBBBB':
			return 'B'
t = int(input())
for i in range(t):
	n = input()
	a = []
	flag = False
	for i in range(8):
		a.append(input())
	for x in a:
		if x == 'RRRRRRRR':
			print('R')
			flag = True
			break
	if not flag:
		print(checkWithTranspse(a))


for _ in range(int(input())):
	k = 'B'
	input()
	for i in range(0, 8):
		if input() == 'RRRRRRRR':
			k = 'R'
	print(k)


t = int(input())
for t_i in range(t):
	bs = input()
	row_complete = False
	for i in range(8):
		r = input()
		if r == 'RRRRRRRR':
			row_complete = True
	print('R' if row_complete else 'B')


t = int(input())
for x in range(t):
	empt = input()
	(flg, smr, smb) = (0, 0, 0)
	for i in range(8):
		l = input()
		if flg == 0 and l.count('R') == 8:
			print('R')
			flg = 1
	if flg == 0:
		print('B')


t = int(input())
for tc in range(t):
	input()
	l = []
	for i in range(8):
		l.append(input())
	if 'RRRRRRRR' in l:
		print('R')
	else:
		print('B')


for _ in range(int(input())):
	input()
	s1 = []
	for i in range(8):
		s1.append(input())
	if 'RRRRRRRR' in s1:
		print('R')
	else:
		print('B')


for KO in range(int(input())):
	str = 'B'
	input()
	for papa in range(0, 8):
		if input() == 'RRRRRRRR':
			str = 'R'
	print(str)


t = int(input())
for _ in range(t):
	a = input()
	s = 'B'
	for j in range(0, 8):
		if input() == 'RRRRRRRR':
			s = 'R'
	print(s)


for _ in ' ' * int(input()):
	_ = input()
	x = 'B'
	for _ in ' ' * 8:
		a = input()
		if a == 'RRRRRRRR':
			x = 'R'
	print(x)


t = int(input())
for _ in range(t):
	input()
	flag = False
	for i in range(8):
		a = input()
		if a == 'R' * 8:
			flag = True
	if flag:
		print('R')
	else:
		print('B')


for _ in range(int(input())):
	n = input()
	l1 = 'RRRRRRRR'
	l = [input() for _ in range(8)]
	print('R' if l1 in l else 'B')


for _ in range(int(input())):
	input()
	found = False
	for i in range(8):
		if input().count('R') == 8:
			found = True
	print('R' if found else 'B')


for h in range(int(input())):
	a = []
	rr = 'B'
	input()
	for i in range(8):
		a = input()
		if a == 'R' * 8:
			rr = 'R'
	print(rr)


t = int(input())
for _ in range(t):
	_ = input()
	arr = [input() for _ in range(8)]
	res = ''
	if 'RRRRRRRR' in arr:
		res = 'R'
	else:
		res = 'B'
	print(res)


T = int(input())
for i in range(T):
	string = 'B'
	input()
	for i in range(0, 8):
		if input() == 'RRRRRRRR':
			string = 'R'
	print(string)


for _ in range(int(input())):
	s = 'B'
	input()
	for i in range(8):
		if input() == 'RRRRRRRR':
			s = 'R'
	print(s)


n = int(input())
data = list((list() for i in range(n)))
for i in range(n):
	x = input()
	for j in range(8):
		data[i].append(input())
for i in range(n):
	for r in range(8):
		rb = True
		cb = True
		for c in range(8):
			if data[i][r][c] != 'R':
				rb = False
			if data[i][c][r] != 'B':
				cb = False
			if rb == False and cb == False:
				break
		if rb:
			print('R')
			break
		elif cb:
			print('B')
			break


t = int(input())
data1 = []
for i in range(t):
	empty = input()
	a = []
	data = []
	for j in range(8):
		d = input()
		data.append(d)
	data1.append(data)
for i in data1:
	for j in range(8):
		if i[j][0] == i[j][1] == i[j][2] == i[j][3] == i[j][4] == i[j][5] == i[j][6] == i[j][7]:
			if i[j][0] == 'R':
				print(i[j][0])
				break
		if i[0][j] == i[1][j] == i[2][j] == i[3][j] == i[4][j] == i[5][j] == i[6][j] == i[7][j]:
			if i[0][j] == 'B':
				print(i[0][j])
				break


t = int(input())
for i in range(t):
	s = input()
	s = ''
	j = 'B'
	for i in range(8):
		k = input()
		if k.count('B') == 0:
			j = 'R'
	print(j)


r = 8 * 'R'
for s in range(int(input())):
	R = 'B'
	for n in range(9):
		m = input()
		if m == r:
			R = 'R'
	print(R)