Vasya has a grid with $2$ rows and $n$ columns. He colours each cell red, green, or blue.

Vasya is colourblind and can't distinguish green from blue. Determine if Vasya will consider the two rows of the grid to be coloured the same.


-----Input-----

The input consists of multiple test cases. The first line contains an integer $t$ ($1 \leq t \leq 100$) — the number of test cases. The description of the test cases follows.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 100$) — the number of columns of the grid.

The following two lines each contain a string consisting of $n$ characters, each of which is either R, G, or B, representing a red, green, or blue cell, respectively — the description of the grid.


-----Output-----

For each test case, output "YES" if Vasya considers the grid's two rows to be identical, and "NO" otherwise.

You can output the answer in any case (for example, the strings "yEs", "yes", "Yes" and "YES" will be recognized as a positive answer).


-----Examples-----

Input
6
2
RG
RB
4
GRBG
GBGB
5
GGGGG
BBBBB
7
BBBBBBB
RRRRRRR
8
RGBRRGBR
RGGRRBGR
1
G
G
Output
YES
NO
YES
NO
YES
YES


-----Note-----

In the first test case, Vasya sees the second cell of each row as the same because the second cell of the first row is green and the second cell of the second row is blue, so he can't distinguish these two cells. The rest of the rows are equal in colour. Therefore, Vasya will say that the two rows are coloured the same, even though they aren't.

In the second test case, Vasya can see that the two rows are different.

In the third test case, every cell is green or blue, so Vasya will think they are the same.

Difficulty: EASY
Tags: Implementation

Starter code:

Solutions:
for Pythonic__Python in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	c = 0
	for i in range(len(s1)):
		if s1[i] == s2[i]:
			c += 1
		elif s1[i] == 'G' and s2[i] == 'B':
			c += 1
		elif s2[i] == 'G' and s1[i] == 'B':
			c += 1
		else:
			break
	if c == n:
		print('YES')
	else:
		print('NO')


import sys

def main():
	n = int(sys.stdin.readline().strip())
	st = 'Timur'
	st = ''.join(sorted(st))
	for _ in range(n):
		sys.stdin.readline()
		s = sys.stdin.readline().strip()
		s2 = sys.stdin.readline().strip()
		s = s.replace('G', 'B')
		s2 = s2.replace('G', 'B')
		if s == s2:
			sys.stdout.write('YES\n')
		else:
			sys.stdout.write('NO\n')
main()


a = int(input())
for i in range(a):
	n = int(input())
	s1 = input()
	s2 = input()
	s1 = s1.replace('G', 'B')
	s2 = s2.replace('G', 'B')
	if s1 == s2:
		print('YES')
	else:
		print('NO')


k = int(input())
while k:
	n = int(input())
	a = input()
	b = input()
	flag = True
	for i in range(n):
		if a[i] == 'R' and b[i] != 'R' or (a[i] != 'R' and b[i] == 'R'):
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')
	k -= 1


for _ in range(int(input())):
	n = int(input())
	x = input()
	y = input()
	c = 0
	for i in range(n):
		if x[i] == y[i] or (x[i] == 'G' and y[i] == 'B') or (x[i] == 'B' and y[i] == 'G'):
			c += 1
	if c == n:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	st1 = list(input())
	st2 = list(input())
	r1 = 0
	r2 = 0
	for i in range(n):
		if st1[i] == 'G':
			st1[i] = 'B'
		if st2[i] == 'G':
			st2[i] = 'B'
	if st1 == st2:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	r1 = input()
	r2 = input()
	flag = True
	for i in range(n):
		if (r1[i] == 'R' or r2[i] == 'R') and r1[i] != r2[i]:
			flag = False
			print('NO')
			break
	if flag:
		print('YES')


for S in range(int(input())):
	input()
	print('YNEOS'[input().replace('G', 'B') != input().replace('G', 'B')::2])


nums = int(input())
while nums != 0:
	column = int(input())
	colors = input()
	colors_ = input()
	if len(colors) != column or len(colors_) != column:
		print('эй вася, считать до ', column, ' разучился?!')
	nums -= 1
	spisok = False
	for i in range(len(colors)):
		if colors[i] == 'R' and colors_[i] == 'R' or ((colors[i] == 'B' or colors[i] == 'G') and (colors_[i] == 'B' or colors_[i] == 'G')):
			spisok = True
		else:
			print('NO')
			spisok = False
			break
	if spisok:
		print('YES')


u = int(input())
for _ in range(u):
	n = int(input())
	f = input()
	s = input()
	m = 0
	for i in range(n):
		if (f[i] == 'G' or f[i] == 'B') and (s[i] == 'G' or s[i] == 'B') or f[i] == s[i]:
			b = 0
		else:
			m = 1
			break
	if m == 1:
		print('NO')
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a1 = input()
	a2 = input()
	f = False
	for i in range(len(a1)):
		if a1[i] == 'R' and a2[i] != 'R' or (a1[i] != 'R' and a2[i] == 'R'):
			f = True
			break
	if f == True:
		print('NO')
	else:
		print('YES')


t = int(input())
while t > 0:
	n = int(input())
	s1 = input()
	s2 = input()
	s3 = s1.replace('G', 'B')
	s4 = s2.replace('G', 'B')
	if s3 == s4:
		print('YES')
	else:
		print('NO')
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input().replace('G', 'B')
	s2 = input().replace('G', 'B')
	print('YES' if s1 == s2 else 'NO')


import sys
input = sys.stdin.readline

def print(*args, end='\n', sep=' ') -> None:
	sys.stdout.write(sep.join(map(str, args)) + end)

def Solve():
	for t in range(int(input())):
		n = int(input())
		a = input().strip('\n')
		b = input().strip('\n')
		a = a.replace('G', 'B')
		b = b.replace('G', 'B')
		print('YES' if a == b else 'NO')
Solve()


import sys
input = lambda : sys.stdin.readline().rstrip()
input_multiple_int = lambda : map(int, input().split())
T = int(input())
for _ in range(T):
	n = int(input())
	s1 = input()
	s2 = input()
	S1 = ''
	S2 = ''
	for i in s1:
		if i == 'B':
			S1 += 'G'
		else:
			S1 += i
	for i in s2:
		if i == 'B':
			S2 += 'G'
		else:
			S2 += i
	print('YES' if S1 == S2 else 'NO')


t = int(input())
for i in range(t):
	n = int(input())
	a = input().replace('G', 'B')
	b = input().replace('G', 'B')
	if a == b:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	r1 = input()
	r2 = input()
	ans = True
	for i in range(len(r1)):
		if not (r1[i] == 'G' and r2[i] == 'B' or (r1[i] == 'B' and r2[i] == 'G') or (r1[i] == 'R' and r2[i] == 'R') or (r1[i] == 'G' and r2[i] == 'G') or (r1[i] == 'B' and r2[i] == 'B')):
			ans = False
	if ans:
		print('YES')
	else:
		print('NO')


import sys
sys.setrecursionlimit(10 ** 6)
ip = sys.stdin.readline
op = sys.stdout.write
t = int(ip())
res = []
for _ in range(t):
	n = int(ip())
	row1 = ip()
	row2 = ip()
	is_same = True
	for i in range(n):
		if row1[i] != row2[i]:
			if row1[i] == 'R' or row2[i] == 'R':
				is_same = False
				break
	if is_same:
		res.append('YES')
	else:
		res.append('NO')
for val in res:
	op(val + '\n')


for i in range(int(input())):
	x = int(input())
	y = input()
	y1 = input()
	ans = 'YES'
	for i in range(x):
		if y[i] == y1[i] or (y[i] == 'G' and y1[i] == 'B') or (y[i] == 'B' and y1[i] == 'G'):
			pass
		else:
			ans = 'NO'
			break
	print(ans)


def check(x, y):
	for (i, j) in zip(x, y):
		if i == j:
			continue
		if (i, j) in (('B', 'G'), ('G', 'B')):
			continue
		return 'NO'
	return 'YES'
for _ in range(int(input())):
	n = int(input())
	(x, y) = (input(), input())
	print(check(x, y))


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	l1 = list(s1)
	l2 = list(s2)
	for i in range(n):
		if l1[i] == 'G':
			l1[i] = 'B'
		if l2[i] == 'G':
			l2[i] = 'B'
	if l1 == l2:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s_ = input()
	s = input()
	s_ = s_.replace('G', 'B')
	s = s.replace('G', 'B')
	if s == s_:
		print('YES')
	else:
		print('NO')


from collections import Counter

def fun(a, b):
	a = list(a)
	b = list(b)
	for i in range(len(a)):
		if a[i] == 'G' or a[i] == 'B':
			a[i] = 'x'
		if b[i] == 'G' or b[i] == 'B':
			b[i] = 'x'
	return a == b
for _ in range(int(input())):
	x = input()
	a = input()
	b = input()
	if fun(a, b):
		print('YES')
	else:
		print('NO')


for caseno in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	answer = True
	for i in range(n):
		curr_count = 0
		if a[i] == 'R':
			curr_count += 1
		if b[i] == 'R':
			curr_count += 1
		if curr_count == 1:
			answer = False
	if answer:
		print('YES')
	else:
		print('NO')


t = int(input())
for ncase in range(1, t + 1):
	n = int(input())
	s1 = [i for i in input()]
	s2 = [i for i in input()]
	for i in range(n):
		if s1[i] == 'G':
			s1[i] = 'B'
		if s2[i] == 'G':
			s2[i] = 'B'
		if s1[i] != s2[i]:
			ans = 'NO'
			break
	else:
		ans = 'YES'
	print(ans)


for _ in range(int(input())):
	n = int(input())
	l = list(input())
	m = list(input())
	for i in range(n):
		if l[i] == 'R' and m[i] != 'R' or (m[i] == 'R' and l[i] != 'R'):
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	flag = 0
	color = ['B', 'G']
	for i in range(n):
		if s1[i] in color and s2[i] in color:
			continue
		elif s1[i] != s2[i]:
			flag = 1
			break
	if flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	flag = 1
	for i in range(n):
		if s1[i] == 'G' or s1[i] == 'B':
			if s2[i] == 'G' or s2[i] == 'B':
				continue
			else:
				flag = 0
				break
		elif s2[i] == 'R':
			continue
		else:
			flag = 0
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	r1 = input()
	r2 = input()
	result = 'YES'
	for i in range(n):
		if r1[i] != r2[i]:
			if r1[i] == 'G' and r2[i] == 'B' or (r1[i] == 'B' and r2[i] == 'G'):
				continue
			else:
				result = 'NO'
				break
	print(result)


n = int(input())
answer = []
for i in range(n):
	b = int(input())
	s = str(input())
	s2 = str(input())
	flag = 0
	for i in range(len(s)):
		if s[i] == s2[i] or (s[i] == 'G' and s2[i] == 'B') or (s2[i] == 'G' and s[i] == 'B'):
			flag += 0
		else:
			flag += 1
	if flag:
		answer.append('NO')
	else:
		answer.append('YES')
for i in answer:
	print(i)


t = int(input())
for _ in range(t):
	n = int(input())
	r1 = input()
	r2 = input()
	new_r1 = ''
	new_r2 = ''
	for i in r1:
		if i == 'R':
			new_r1 += i
		else:
			new_r1 += 'B'
	for i in r2:
		if i == 'R':
			new_r2 += i
		else:
			new_r2 += 'B'
	print('YES' if new_r1 == new_r2 else 'NO')


for _ in range(int(input())):
	n = int(input())
	s1 = input()
	s2 = input()
	k = 0
	for i in range(n):
		if s1[i] == 'R' and s2[i] == 'G' or (s1[i] == 'G' and s2[i] == 'R') or (s1[i] == 'B' and s2[i] == 'R') or (s1[i] == 'R' and s2[i] == 'B'):
			k = 1
			break
	if k == 1:
		print('NO')
	else:
		print('YES')


for _ in range(int(input())):
	a = int(input())
	x = input()
	y = input()
	for i in range(a):
		if x[i] == 'R' and y[i] == 'G' or (x[i] == 'G' and y[i] == 'R'):
			print('NO')
			break
		elif x[i] == 'R' and y[i] == 'B' or (x[i] == 'B' and y[i] == 'R'):
			print('NO')
			break
	else:
		print('YES')


I = input
for _ in ' ' * int(I()):
	n = int(I())
	t = 0
	a = I()
	b = I()
	print('YNEOS'[sum((a[i] == b[i] or a[i] + b[i] in 'GBBG' for i in range(n))) != n::2])


num_inp = lambda : int(input())
arr_inp = lambda : list(map(int, input().split()))
sp_inp = lambda : map(int, input().split())
str_inp = lambda : input()
t = num_inp()
for _ in range(t):
	n = num_inp()
	f = str_inp()
	s = str_inp()
	for i in range(n):
		if f[i] != s[i]:
			if f[i] == 'G' and s[i] == 'B':
				continue
			if f[i] == 'B' and s[i] == 'G':
				continue
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	a = int(input())
	a1 = input().replace('G', 'B')
	a2 = input().replace('G', 'B')
	if a1 == a2:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	f = True
	for i in range(n):
		if not (s1[i] == s2[i] or (s1[i] == 'G' and s2[i] == 'B' or (s1[i] == 'B' and s2[i] == 'G'))):
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


T = int(input())

def fn(a, b):
	for i in range(len(a)):
		if a[i] != b[i]:
			if a[i] == 'R' or b[i] == 'R':
				return 'NO'
	return 'YES'
for _ in range(T):
	l = int(input())
	a = input()
	b = input()
	print(fn(a, b))


t = int(input())
for j in range(t):
	n = int(input())
	a = input()
	b = input()
	word = ''
	for j in range(n):
		if a[j] == 'B' and b[j] == 'B':
			word += 'B'
		elif a[j] == 'G' and b[j] == 'G':
			word += 'G'
		elif a[j] == 'B' and b[j] == 'G':
			word += 'G'
		elif a[j] == 'G' and b[j] == 'B':
			word += 'B'
		elif a[j] == 'R' and b[j] == 'R':
			word += 'R'
	if word == b:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a1 = input()
	a2 = input()
	jeste = True
	for i in range(n):
		if a1[i].upper() == 'R' and a2[i].upper() != 'R':
			jeste = False
		if a2[i].upper() == 'R' and a1[i].upper() != 'R':
			jeste = False
	if jeste:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	cnt = 0
	for i in range(n):
		if a[i] == 'R' and b[i] == 'R':
			cnt += 1
	res = max(a.count('R'), b.count('R'))
	if cnt == res:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	toPrint = True
	for i in range(n):
		sum_ = ord(s1[i]) + ord(s2[i])
		if sum_ in [153, 148]:
			print('NO')
			toPrint = False
			break
	if toPrint:
		print('YES')


for _ in range(int(input())):
	x = int(input())
	s = input()
	s1 = input()
	c = 0
	for (i, j) in zip(s, s1):
		if i == j:
			continue
		elif i == 'G' and j == 'B' or (j == 'G' and i == 'B'):
			continue
		else:
			c += 1
			break
	if c:
		print('NO')
	else:
		print('YES')


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	k = input()
	h = 0
	for i in range(n):
		if s[i] == 'R' and k[i] == 'R':
			h += 1
		elif (s[i] == 'B' or s[i] == 'G') and (k[i] == 'B' or k[i] == 'G'):
			h += 1
	if h == n:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	p = input()
	q = input()
	if p.replace('G', 'B') == q.replace('G', 'B'):
		print('YES')
	else:
		print('NO')


def wonder(n, st1, st2):
	if st1 == st2:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for _ in range(0, t):
	n = int(input())
	st1 = input()
	st2 = input()
	st1 = st1.replace('G', 'B')
	st2 = st2.replace('G', 'B')
	response = wonder(n, st1, st2)
	print(f'{response}')


a = int(input())
for i in range(a):
	s = int(input())
	n1 = input()
	n2 = input()
	if len(n1) and len(n2) == s:
		for m in n1:
			if m in ['R', 'G', 'B']:
				continue
			else:
				print('NO')
				break
		else:
			for j in n2:
				if j in ['R', 'G', 'B']:
					continue
				else:
					print('NO')
					break
			else:
				for g in range(s):
					if n1[g] == n2[g]:
						continue
					elif n1[g] == 'G' and n2[g] == 'B':
						continue
					elif n1[g] == 'B' and n2[g] == 'G':
						continue
					else:
						print('NO')
						break
				else:
					print('YES')
	else:
		print('NO')


t = int(input(''))
while t:
	t -= 1
	l = int(input(''))
	s1 = input('')
	s2 = input('')
	count = 0
	s3 = [ele.replace('G', 'B') for ele in s1]
	s4 = [ele.replace('G', 'B') for ele in s2]
	for i in range(0, l):
		if s3[i] == s4[i]:
			if i == l - 1:
				print('YES')
		else:
			print('NO')
			break


for t in range(int(input())):
	n = int(input())
	y = input()
	x = input()
	j = 0
	for i in range(n):
		if y[i] == 'R' and x[i] == 'G':
			j = 10
			break
		if y[i] == 'R' and x[i] == 'B':
			j = 10
			break
		if y[i] == 'G' and x[i] == 'R':
			j = 10
			break
		if y[i] == 'B' and x[i] == 'R':
			j = 10
			break
	if j == 10:
		print('NO')
	else:
		print('YES')


a = int(input())
for z in range(a):
	b = int(input())
	b = input()
	c = input()
	d = True
	for y in range(len(b)):
		if b[y] in ['R', 'G', 'B'] or c[y] in ['R', 'G', 'B']:
			if b[y] != c[y]:
				if b[y] not in ['B', 'G'] or c[y] not in ['B', 'G']:
					d = False
		else:
			d = False
	if d:
		print('YES')
	else:
		print('NO')


t = int(input(''))
for i in range(t):
	n = int(input(''))
	r1 = input('')
	r2 = input('')
	r1s = []
	r2s = []
	for j in range(n):
		if r1[j] == 'R':
			r1s.append('R')
		else:
			r1s.append('O')
		if r2[j] == 'R':
			r2s.append('R')
		else:
			r2s.append('O')
	if r1s == r2s:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	N = int(input())
	q = input()
	w = input()
	for x in range(N):
		if q[x] == 'R' and w[x] == 'G':
			flag = 1
			break
		elif q[x] == 'G' and w[x] == 'R':
			flag = 1
			break
		elif q[x] == 'R' and w[x] == 'B':
			flag = 1
			break
		elif q[x] == 'B' and w[x] == 'R':
			flag = 1
			break
		else:
			flag = 0
	if flag != 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	s1 = input()
	s2 = input()
	good = True
	for c in range(0, n):
		if s1[c] == 'R' and s2[c] != 'R':
			good = False
			break
		elif s2[c] == 'R' and s1[c] != 'R':
			good = False
			break
	if good:
		print('YES')
	else:
		print('NO')


a = int(input())
for i in range(a):
	b = int(input())
	c = list(input())
	d = list(input())
	r = 0
	for k in range(len(c)):
		if c[k] == d[k] or (c[k] == 'G' and d[k] == 'B' or (c[k] == 'B' and d[k] == 'G')):
			r += 1
		else:
			break
	if r == len(c):
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	l1 = input()
	l2 = input()
	for i in range(n):
		if l1[i] != 'R' and l2[i] == 'R' or (l1[i] == 'R' and l2[i] != 'R'):
			print('NO')
			break
	else:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	b = input()
	c = 0
	for i in range(len(a)):
		if a[i] == b[i] == 'R':
			c += 1
	if c == a.count('R') and c == b.count('R'):
		print('YES')
	else:
		print('NO')


s = [input() for i in range(int(input()) * 3)]
colors = []
for i in s:
	if i.isalpha():
		colors.append(i.replace('G', 'B'))
for i in range(0, len(colors), 2):
	if colors[i] == colors[i + 1]:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	s1 = input()
	cou = 0
	s = s.replace('B', 'G')
	s1 = s1.replace('B', 'G')
	for p in range(0, n):
		if s1[p] != s[p]:
			cou = cou + 1
	if cou == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = input()
	b = input()
	c = 0
	f = 0
	for i in range(n):
		if a[i] == 'R' or b[i] == 'R':
			f = f + 1
			if a[i] == b[i]:
				c = c + 1
	if f == c:
		print('YES')
	else:
		print('NO')


import sys

def check(top, bottom, n):
	for i in range(n):
		if top[i] == 'R' and bottom[i] != 'R' or (top[i] != 'R' and bottom[i] == 'R'):
			return False
	return True
T = int(input())
for qwer in range(T):
	col = int(input())
	top = input()
	bottom = input()
	if check(top, bottom, col):
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	row1 = input()
	row2 = input()
	c = 0
	for i in range(n):
		if row1[i] == row2[i] or (row1[i] == 'G' and row2[i] == 'B') or (row1[i] == 'B' and row2[i] == 'G'):
			c += 1
	if c == n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(0, t):
	n = int(input())
	s1 = str(input())
	s2 = str(input())
	found = True
	for i in range(0, len(s2)):
		if s1[i] == 'G' and s2[i] == 'B':
			continue
		elif s1[i] == 'B' and s2[i] == 'G':
			continue
		elif s1[i] != s2[i]:
			print('NO')
			found = False
			break
	if found:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	string1 = input()
	string2 = input()
	ans = 0
	k = 0
	for i in range(len(string1)):
		if string1[i] == string2[i] or (string1[i] == 'B' and string2[i] == 'G' or (string1[i] == 'G' and string2[i] == 'B')):
			ans += 1
	if ans == n:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n = int(input())
	s1 = input()
	s2 = input()
	s3 = s1.replace('G', 'B')
	s4 = s2.replace('G', 'B')
	if s3 == s4:
		print('YES')
	else:
		print('NO')