A row of $n$ cells is given, all initially white. Using a stamp, you can stamp any two neighboring cells such that one becomes red and the other becomes blue. A stamp can be rotated, i.e. it can be used in both ways: as $\color{blue}{{B}}{{R}}$ and as ${{R}}\color{blue}{{B}}$.

During use, the stamp must completely fit on the given $n$ cells (it cannot be partially outside the cells). The stamp can be applied multiple times to the same cell. Each usage of the stamp recolors both cells that are under the stamp.

For example, one possible sequence of stamps to make the picture $\color{blue}{{B}}{{R}}\color{blue}{{B}}\color{blue}{{B}}{W}$ could be ${WWWWW} \to {WW}\color{brown}{\underline{{{R}}\color{blue}{{B}}}}{W} \to \color{brown}{\underline{\color{blue}{{B}}{{R}}}}{{R}}\color{blue}{{B}}{W} \to \color{blue}{{B}}\color{brown}{\underline{{{R}}\color{blue}{{B}}}}\color{blue}{{B}}{W}$. Here ${W}$, ${{R}}$, and $\color{blue}{{B}}$ represent a white, red, or blue cell, respectively, and the cells that the stamp is used on are marked with an underline.

Given a final picture, is it possible to make it using the stamp zero or more times?


-----Input-----

The first line contains an integer $t$ ($1 \leq t \leq 10^4$) — the number of test cases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 10^5$) — the length of the picture.

The second line of each test case contains a string $s$ — the picture you need to make. It is guaranteed that the length of $s$ is $n$ and that $s$ only consists of the characters ${W}$, ${R}$, and ${B}$, representing a white, red, or blue cell, respectively.

It is guaranteed that the sum of $n$ over all test cases does not exceed $10^5$.


-----Output-----

Output $t$ lines, each of which contains the answer to the corresponding test case. As an answer, output "YES" if it possible to make the picture using the stamp zero or more times, 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
12
5
BRBBW
1
B
2
WB
2
RW
3
BRB
3
RBB
7
WWWWWWW
9
RBWBWRRBW
10
BRBRBRBRRB
12
BBBRWWRRRWBR
10
BRBRBRBRBW
5
RBWBW
Output
YES
NO
NO
NO
YES
YES
YES
NO
YES
NO
YES
NO


-----Note-----

The first test case is explained in the statement.

For the second, third, and fourth test cases, it is not possible to stamp a single cell, so the answer is "NO".

For the fifth test case, you can use the stamp as follows: ${WWW} \to {W}\color{brown}{\underline{{{R}}\color{blue}{{B}}}} \to \color{brown}{\underline{\color{blue}{{B}}{{R}}}}\color{blue}{{B}}$.

For the sixth test case, you can use the stamp as follows: ${WWW} \to {W}\color{brown}{\underline{{{R}}\color{blue}{{B}}}} \to \color{brown}{\underline{{{R}}\color{blue}{{B}}}}\color{blue}{{B}}$.

For the seventh test case, you don't need to use the stamp at all.

Source: codeforces | Difficulty: EASY
Tags: Implementation


Solutions:
from sys import stdin, stdout

def main():
	t = int(stdin.readline())
	for _ in range(t):
		n = int(stdin.readline())
		input_arr = stdin.readline().strip().split('W')
		is_valid = True
		for colors in input_arr:
			if not colors:
				continue
			if 'B' not in colors or 'R' not in colors:
				is_valid = False
				break
		print('YES' if is_valid else 'NO')
main()


for s in [*open(0)][2::2]:
	print('YNEOS'[1 in map(len, map(set, s[:-1].split('W')))::2])


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	str_ = input().strip()
	answer = True
	for substr_ in str_.split('W'):
		if len(substr_) == 0:
			continue
		if substr_.count('R') == 0 or substr_.count('B') == 0:
			answer = False
			break
	if answer:
		print('YES')
	else:
		print('NO')


def main():
	l = 1
	T = int(input())
	out = ''
	while l != T + 1:
		N = int(input())
		S = input()
		out += f'{solve(N, S)}\n'
		l += 1
	print(out, flush=True)

def solve(N, S):
	if S == N * 'W':
		return 'YES'
	if 'B' in S and 'R' not in S or ('B' not in S and 'R' in S):
		return 'NO'
	if 'W' not in S:
		return 'YES'
	for subS in S.split('W'):
		if 'B' in subS and 'R' not in subS or ('R' in subS and 'B' not in subS):
			return 'NO'
	return 'YES'
main()


import sys

def get():
	return sys.stdin.readline()

def put(s):
	sys.stdout.write(s)
for _ in range(int(get())):
	n = int(get())
	s = list(get().strip().split('W'))
	flag = True
	for i in s:
		if len(i) != 0 and len(set(i)) < 2:
			put('NO\n')
			flag = False
			break
	if not flag:
		continue
	put('YES\n')


for s in [*open(0)][2::2]:
	print('YNEOS'[1 in [len({*x}) for x in s[:-1].split('W')]::2])


T = int(input())
output = ''
for test in range(T):
	n = int(input())
	chars = input().split('W')
	r = True
	for char in chars:
		if len(set(char)) == 1:
			r = False
			break
	if r:
		output += 'YES\n'
	else:
		output += 'NO\n'
print(output[:-1])


import sys
line = sys.stdin.readline().strip()
number = int(line)

def check(s):
	if len(s) == 0:
		return True
	if len(s) == 1:
		return False
	all_same = True
	for (i, c) in enumerate(s):
		if i == 0:
			continue
		if s[i] != s[i - 1]:
			all_same = False
			break
	return not all_same
for _ in range(number):
	n = int(sys.stdin.readline().strip())
	s = sys.stdin.readline().strip()
	ans = 'YES'
	for sub_s in s.split('W'):
		if not check(sub_s):
			ans = 'NO'
			break
	print(ans)


from itertools import combinations
import sys
input = sys.stdin.readline
for _ in range(int(input().rstrip())):
	t = int(input().rstrip())
	s = input().rstrip()
	elements = s.split('W')
	answer = 'YES'
	for element in elements:
		if element != '':
			c = element[0]
			for e in element:
				if c != e:
					break
			else:
				answer = 'NO'
	else:
		print(answer)


t = int(input())
rrr = ''
yes = 'YES'
no = 'NO'
for _t in range(t):
	n = int(input())
	s = input()
	r = yes
	for z in [x for x in s.split('W') if x != '']:
		if n == 1 or len(z) == 1:
			r = no
			break
		elif len(set([x for x in z])) == 1:
			r = no
			break
	rrr += r + '\n'
print(rrr)


t = int(input())
out = ''
for _ in range(t):
	n = int(input())
	seq = input().split('W')
	for s in seq:
		if s == '':
			continue
		if 'R' not in s or 'B' not in s:
			out += 'NO\n'
			break
	else:
		out += 'YES\n'
print(out)


def solve(s):
	groups = s.split('W')
	for comb in groups:
		if comb != '':
			if len(comb) < 2:
				return 'NO'
			elif comb.count('B') == 0 or comb.count('R') == 0:
				return 'NO'
	return 'YES'
t = int(input())
cases = []
for i in range(t):
	input()
	cases.append(input())
ans = []
for case in cases:
	ans.append(solve(case))
for answer in ans:
	print(answer)


import sys
input = lambda : sys.stdin.readline().strip()
for _ in range(int(input())):
	n = int(input())
	a = input()
	a = a.split('W')
	for i in range(len(a)):
		if a[i] == '':
			continue
		if 'B' in a[i] and 'R' in a[i]:
			continue
		else:
			print('NO')
			break
	else:
		print('YES')


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	ok = True
	n = int(input())
	s = input().rstrip()
	a = s.split('W')
	for x in a:
		if len(set(list(x))) == 1:
			ok = False
			break
	if ok:
		print('YES')
	else:
		print('NO')


t = int(input())
answers = []
for te in range(t):
	n = int(input())
	s = input().split('W')
	bad = False
	for l in s:
		b1 = 'R' in l
		b2 = 'B' in l
		if b1 ^ b2:
			bad = True
	answers.append('NO' if bad else 'YES')
for i in answers:
	print(i)


import sys
input = sys.stdin.readline

def solve():
	n = int(input())
	inp = input()
	inp = inp.replace('\n', '') + 'W'
	ps = inp.split('W')
	for s in ps:
		if len(set(s)) == 1:
			print('NO')
			return
	print('YES')
tst = int(input())
for tt in range(tst):
	solve()


def value(string):
	split_string = string.split('W')
	set_string = [len(set(list(item))) for item in split_string]
	if 1 in set_string:
		return 'NO'
	else:
		return 'YES'

def main():
	n = int(input())
	data = []
	for i in range(n):
		count = int(input())
		string = input()
		data.append(string)
	for string in data:
		print(value(string))
main()


for s in [*open(0)][2::2]:
	s = s.strip()
	(l, b, r, w) = (len(s), 0, 0, 0)
	for i in s:
		if i != 'W' and w:
			(w, b, r) = (0, 0, 0)
		if i == 'B':
			b = 1
		elif i == 'R':
			r = 1
		elif b != r:
			break
		else:
			w = 1
	print('YES' if b == r else 'NO')


def fn(S):
	h = S.split('W')
	for k in h:
		if k != '':
			if len(k) == 1:
				return 'NO'
			A = 0
			B = 0
			for j in k:
				if j == 'B':
					A += 1
				else:
					B += 1
			if A == 0 or B == 0:
				return 'NO'
	return 'YES'
a = int(input())
h = []
for i in range(a):
	b = input()
	c = input()
	h.append(fn(c))
for j in range(a):
	print(h[j])


t = int(input())
res = []
for _ in range(t):
	n = int(input())
	s = input()
	cntR = 0
	cntB = 0
	pr = True
	for ch in s:
		if ch == 'R':
			cntR += 1
		elif ch == 'B':
			cntB += 1
		else:
			if cntR * cntB == 0 and cntR + cntB > 0:
				pr = False
				break
			cntR = 0
			cntB = 0
	if cntR * cntB == 0 and cntR + cntB > 0:
		pr = False
	if pr:
		res.append('YES')
	else:
		res.append('NO')
for i in res:
	print(i)


import sys
import itertools
si = sys.stdin.readline
t = int(si())
for _ in range(t):
	n = int(si())
	colors = si().rstrip().split('W')
	isTrue = True
	for color in colors:
		if color == '':
			continue
		if len(color) == 1:
			isTrue = False
		(red, blue) = (0, 0)
		for c in color:
			if c == 'B':
				blue += 1
			else:
				red += 1
		if red == 0 or blue == 0:
			isTrue = False
	print('YES' if isTrue else 'NO')


import math, bisect, heapq, random, sys, itertools
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline

def gprint(t, ans=''):
	print(f'Case #{t + 1}:', ans)
ints = lambda : list(map(int, input().split()))
alpha = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
p2 = [1]
p = 10 ** 9 + 7
ANS = []
for t in range(int(input())):
	n = int(input())
	a = 'W' + input().strip() + 'W'
	c = 'YES'
	x = ''
	for i in range(len(a)):
		if a[i] == 'W':
			if len(x) == 1:
				c = 'NO'
				break
			if len(set(list(x))) == 1:
				c = 'NO'
				break
			x = ''
		else:
			x += a[i]
	print(c)


import math
t = int(input())
sas = list()
for vvod in range(t):
	ans = 'YES'
	n = int(input())
	s = input()
	d = dict()
	d['R'] = 0
	d['B'] = 0
	if n == 1:
		if s == 'W':
			sas.append('YES')
		else:
			sas.append('NO')
		continue
	s += 'W'
	for i in s:
		if i == 'R':
			d[i] += 1
		elif i == 'B':
			d[i] += 1
		elif d['R'] > 0 and d['B'] == 0:
			ans = 'NO'
			break
		elif d['R'] == 0 and d['B'] > 0:
			ans = 'NO'
			break
		else:
			d['R'] = 0
			d['B'] = 0
	sas.append(ans)
for i in range(t):
	print(sas[i])


t = int(input())
res = ''
for _ in range(t):
	n = int(input())
	formt = input().split('W')
	formt = [formt[i] for i in range(len(formt)) if len(formt[i]) > 0]
	flag = True
	for it in formt:
		init_char = it[0]
		if len(it) == 1:
			flag = False
			break
		tmp_flag = False
		for idx in range(len(it)):
			if it[idx] != init_char:
				tmp_flag = True
				break
		if tmp_flag is False:
			flag = False
			break
	if flag is True:
		res += 'YES\n'
	else:
		res += 'NO\n'
print(res)


y = []
n = int(input())
for i in range(n):
	n1 = int(input())
	x = input()
	flag = 1
	x1 = 0
	x2 = 0
	for j in range(n1):
		if x[j] == 'W':
			if x1 == 0 and x2 != 0:
				y.append('NO')
				flag = 0
				break
			if x1 != 0 and x2 == 0:
				y.append('NO')
				flag = 0
				break
			x1 = 0
			x2 = 0
		if x[j] == 'R':
			x1 = x1 + 1
		if x[j] == 'B':
			x2 = x2 + 1
	if flag == 1:
		if x1 == 0 and x2 != 0:
			y.append('NO')
			flag = 0
			continue
		if x1 != 0 and x2 == 0:
			y.append('NO')
			flag = 0
			continue
	if flag == 1:
		y.append('YES')
for i in range(len(y)):
	print(y[i])


import sys
input = lambda : sys.stdin.readline().strip()
for i in range(int(input())):
	l = int(input())
	s = str(input())
	a = 0
	b = 0
	s += 'W'
	ans = 'YES'
	for i in range(l + 1):
		if s[i] == 'R':
			a += 1
		elif s[i] == 'B':
			b += 1
		else:
			if a == 0 and b != 0 or (b == 0 and a != 0):
				ans = 'NO'
			a = 0
			b = 0
	print(ans)


from itertools import groupby
from sys import stdin
from math import log, floor, ceil, gcd
from collections import defaultdict as dd
input = stdin.readline
inp = lambda : int(stdin.readline())
rs = lambda : stdin.readline().strip()

def ra(typ):
	return list(map(typ, stdin.readline().split()))

def rv(typ):
	return map(typ, stdin.readline().split())

def main():
	for _ in range(inp()):
		n = inp()
		s = rs()
		l = [k for (k, g) in groupby(s)]
		ans = True
		x = len(l)
		try:
			for i in range(x):
				if i <= x - 2:
					if l[i] == 'B' and l[i + 1] != 'R':
						if i - 1 < 0 or l[i - 1] != 'R':
							ans = False
							break
					elif l[i] == 'R' and l[i + 1] != 'B':
						if i - 1 < 0 or l[i - 1] != 'B':
							ans = False
							break
				elif l[i] == 'B' and l[i - 1] != 'R':
					ans = False
					break
				elif l[i] == 'R' and l[i - 1] != 'B':
					ans = False
					break
		except:
			ans = False
		print('YES' if ans else 'NO')
main()


import tempfile

def get_input():
	al = []
	for c in range(int(input())):
		input()
		n = input()
		al.append(n)
	return al

def calc(arr):
	r = 0
	b = 0
	new = 0
	for s in arr:
		if s == 'W':
			if new == 0:
				continue
			elif b == 0 or r == 0:
				print('NO')
				return
			else:
				new = 0
				b = 0
				r = 0
				continue
		new = 1
		if s == 'B':
			b = 1
		elif s == 'R':
			r = 1
	if b == 0 and r == 0:
		print('YES')
	elif b == 0 or r == 0:
		print('NO')
	else:
		print('YES')

def main():
	arr_list = get_input()
	for arr in arr_list:
		calc(arr)
main()


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())
t = inp()
for test in range(t):
	n = inp()
	chars = insr()
	chars.insert(0, 'W')
	chars.append('W')
	(count, res) = (0, True)
	for i in range(1, n + 2):
		if chars[i] == 'W' and count == 1:
			res = False
			break
		if chars[i] in ['B', 'R'] and chars[i] != chars[i - 1]:
			count += 1
		if chars[i] == 'W':
			count = 0
	if res == False:
		print('NO')
	else:
		print('YES')


import sys
m = int(sys.stdin.readline().strip())
for k in range(m):
	n = int(sys.stdin.readline().strip())
	line = sys.stdin.readline().strip().split('W')
	ans = 'YES'
	for i in range(len(line)):
		if line[i] != '':
			l = set(list(line[i]))
			if len(l) == 1:
				ans = 'NO'
	print(ans)


t = int(input())
answers = []
for i in range(t):
	length = int(input())
	arr = input()
	answer = 'YES'
	substrings = arr.split('W')
	for j in range(len(substrings)):
		red = substrings[j].count('R')
		blue = substrings[j].count('B')
		if red != 0 and blue == 0 or (red == 0 and blue != 0):
			answer = 'NO'
			break
	answers.append(answer)
for i in range(t):
	print(answers[i])


import sys
from typing import Tuple
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 inps():
	return str(input()).strip()
T = inp()
for i in range(T):
	s = int(input())
	string = inps()
	result = True
	b = 0
	r = 0
	if s == 1:
		if string == 'R' or string == 'B':
			result = False
	else:
		for (i, e) in enumerate(string):
			if e == 'W':
				if r == 0 and b > 0 or (b == 0 and r > 0):
					result = False
					break
				r = 0
				b = 0
			elif e == 'R':
				r += 1
			else:
				b += 1
		if r == 0 and b > 0 or (b == 0 and r > 0):
			result = False
	if result:
		print('YES')
	else:
		print('NO')


from random import getrandbits
RANDOM = getrandbits(32)

class Wrapper(int):

	def __init__(self, x):
		int.__init__(x)

	def __hash__(self):
		return super(Wrapper, self).__hash__() ^ RANDOM
T = int(input())
q = []
for i in range(T):
	n = int(input())
	arr = input()
	q.append((arr, n))

def solve(arr, n):
	ls = []
	ss = ''
	for a in arr:
		if a == 'W':
			if ss != '':
				ls.append(ss)
			ss = ''
		else:
			ss += a
	if ss != '':
		ls.append(ss)
	for l in ls:
		if len(l) == 1:
			print('NO')
			return
		if len(l) == 0:
			continue
		R = 0
		B = 0
		for ch in l:
			if ch == 'R':
				R += 1
			if ch == 'B':
				B += 1
		if R == 0 or B == 0:
			print('NO')
			return
	print('YES')
for (arr, n) in q:
	solve(arr, n)


import sys
input = sys.stdin.readline
import re
for _ in range(int(input())):
	n = int(input())
	s = re.split('W+', input()[:-1])
	for i in s:
		if 'B' in i and 'R' not in i or ('R' in i and 'B' not in i):
			print('NO')
			break
	else:
		print('YES')


import math as m
i = input()
inp = []
for a in range(0, int(i)):
	input()
	inp += [input()]

def not_poss(s):
	n = len(s)
	if n == 1:
		return True
	elif s.count('B') == 0 or s.count('R') == 0:
		return True
	return False
for s in inp:
	arr = s.split('W')
	p = 'YES'
	for x in arr:
		if x != '' and not_poss(x):
			p = 'NO'
	print(p)


n_tests = int(input())
ans = [True] * n_tests
for i in range(n_tests):
	n = int(input())
	s = input()
	parts = s.split('W')
	for part in parts:
		if part != '' and (not (part.find('R') >= 0 and part.find('B') >= 0)):
			ans[i] = False
			break
for i in range(n_tests):
	print('YES' if ans[i] else 'NO')


t = int(input())

def f(line):
	b = False
	r = False
	for i in line:
		if i == 'W':
			if b and (not r) or (r and (not b)):
				return False
			else:
				b = False
				r = False
		if i == 'B':
			b = True
		if i == 'R':
			r = True
	return b and r or (not b and (not r))
for i in range(t):
	n = int(input())
	line = input()
	if f(line):
		print('YES')
	else:
		print('NO')


def judge(s):
	meet_r = False
	meet_b = False
	for i in range(len(s)):
		if s[i] == 'B':
			meet_b = True
		elif s[i] == 'R':
			meet_r = True
		elif meet_r == meet_b:
			meet_r = False
			meet_b = False
		else:
			return 'NO'
	if meet_r == meet_b:
		return 'YES'
	else:
		return 'NO'

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		print(judge(s))
main()


import sys

def get_numbers():
	return map(int, sys.stdin.readline().strip().split())
t = int(input())
for i in range(t):
	n = int(input())
	string = input()
	words = string.split('W')
	flag = True
	for word in words:
		if word:
			if 'R' not in word or 'B' not in word:
				flag = False
				break
	if n == 1 and string != 'W':
		flag = False
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	a = input().split('W')
	ans = 'YES'
	for s in a:
		if s == '':
			continue
		(x1, x2) = ('R' in s, 'B' in s)
		if not (x1 and x2):
			ans = 'NO'
			break
	print(ans)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = s.split('W')
	flag = True
	for i in a:
		if len(i) == 1:
			flag = False
			break
		if len(i) == 0:
			continue
		if i.count(i[0]) == len(i):
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	s = input()
	data = s.split('W')
	for x in data:
		if x == '':
			continue
		if 'R' in x and 'B' in x:
			continue
		else:
			print('NO')
			return
	print('YES')
for _ in range(int(input())):
	solve()


import sys, math
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	t = s[0]
	f = s[0]
	if n == 1:
		if s[0] == 'W':
			print('YES')
		else:
			print('NO')
	else:
		for i in range(n):
			if s[i] == f:
				continue
			else:
				t = t + s[i]
				f = s[i]
		if len(t) == 1:
			if t == 'W':
				print('YES')
			else:
				print('NO')
		else:
			for i in range(1, len(t) - 1):
				if t[i] == 'B':
					if t[i - 1] == 'R' or t[i + 1] == 'R':
						continue
					else:
						print('NO')
						break
				elif t[i] == 'R':
					if t[i - 1] == 'B' or t[i + 1] == 'B':
						continue
					else:
						print('NO')
						break
			else:
				c = 0
				if t[0] == 'R' and t[1] == 'B':
					pass
				elif t[0] == 'B' and t[1] == 'R':
					pass
				elif t[0] == 'W':
					pass
				else:
					c = 1
				if t[-1] == 'R' and t[-2] == 'B':
					pass
				elif t[-1] == 'B' and t[-2] == 'R':
					pass
				elif t[-1] == 'W':
					pass
				else:
					c = 1
				if c == 1:
					print('NO')
				else:
					print('YES')


for j in range(int(input())):
	input()
	a = str(input())
	b = a.split('W')
	c = True
	for i in b:
		if i == '':
			continue
		if not ('R' in i and 'B' in i):
			print('NO')
			c = False
			break
	if c:
		print('YES')


def d():
	n = int(input())
	sections = input().split('W')
	for section in sections:
		if len(section) == '1':
			return False
		elif 'B' in section and (not 'R' in section) or ('R' in section and (not 'B' in section)):
			return False
	return True

def main():
	for _ in range(int(input())):
		if d():
			print('YES')
		else:
			print('NO')
main()


import sys

def get_ints():
	return map(int, sys.stdin.readline().strip().split())

def get_ls():
	return list(map(int, sys.stdin.readline().strip().split()))

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		s = s.split('W')
		ok = False
		for x in s:
			a = 'R' in x
			b = 'B' in x
			if a ^ b:
				ok = True
		print('NO' if ok else 'YES')
main()


for _ in range(int(input())):
	a = int(input())
	b = input()
	if a == 1 and b == 'W':
		print('YES')
	elif a == 1:
		print('NO')
	elif a == 2:
		if b == 'BR' or b == 'RB' or b == 'WW':
			print('YES')
		else:
			print('NO')
	else:
		flag = 0
		t = b.split('W')
		for i in t:
			if len(i) == 0:
				continue
			elif len(i) == 1:
				flag = 1
				print('NO')
				break
			elif 'B' not in i or 'R' not in i:
				flag = 1
				print('NO')
				break
		if flag == 0:
			print('YES')


t = int(input())
for _ in range(t):
	failed = False
	n = int(input())
	lst = input().split('W')
	for i in lst:
		if 'R' in i and 'B' not in i:
			failed = True
		elif 'R' not in i and 'B' in i:
			failed = True
	if failed:
		print('NO')
	else:
		print('YES')


def solve():
	n = int(input())
	pic = input()
	arr = pic.split('W')
	arr = [i for i in arr if i]
	flag = False
	for str1 in arr:
		if 'R' not in str1 or 'B' not in str1:
			flag = True
			break
	if flag:
		print('NO')
	else:
		print('YES')
cases = int(input())
for i in range(cases):
	solve()


def its_possible_zero(stamp):
	sp = stamp.split('W')
	for spi in sp:
		if ('R' in spi) ^ ('B' in spi):
			return 'NO'
	return 'YES'

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		print(its_possible_zero(input()))
main()


t = int(input())
for _ in range(t):
	input()
	s = input().split('W')
	ans = 'YES'
	for i in s:
		if len(i) == 0:
			continue
		if len(i) == 1:
			ans = 'NO'
			break
		if i.count('B') == len(i):
			ans = 'NO'
			break
		if i.count('R') == len(i):
			ans = 'NO'
			break
	print(ans)


def Test(n, l):
	for i in l.split('W'):
		if not i:
			continue
		if not 'R' in i or not 'B' in i:
			print('NO')
			return
	print('YES')
for j in range(int(input())):
	n = int(input())
	l = input()
	Test(n, l)


def solve():
	for s in S.split('W'):
		if s:
			color = s[0]
			if len(s) == 1 or all((x == color for x in s)):
				return 'NO'
	return 'YES'
number_of_cases = int(input())
for case_num in range(1, number_of_cases + 1):
	N = int(input())
	S = input()
	print(f'{solve()}')


for _ in range(int(input())):
	length = int(input())
	arr = input()
	list_ = []
	temp = ''
	flag = True
	list_ = list(arr.split('W'))
	for ele in list_:
		if ele:
			if 'B' not in ele or 'R' not in ele:
				flag = False
				break
	if not flag:
		print('NO')
	else:
		print('YES')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input().split('W')
	for x in s:
		if len(x) == 0:
			continue
		if not ('RB' in x or 'BR' in x):
			print('NO')
			break
	else:
		print('YES')


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input().split('W')
	ok = 'YES'
	for v in s:
		if v == '':
			continue
		if 'BR' in v or 'RB' in v:
			continue
		ok = 'NO'
		break
	print(ok)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input().strip().split('W')
	flag = True
	for i in s:
		if i == '':
			continue
		if len(i) < 2:
			flag = False
			break
		elif not ('B' in i and 'R' in i):
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


def help(s):
	if len(s) == 0:
		return True
	if len(s) == 1:
		return False
	c1 = 0
	c2 = 0
	for i in s:
		if i == 'B':
			c1 += 1
		else:
			c2 += 1
	if c1 == 0 or c2 == 0:
		return False
	return True
for _ in range(int(input())):
	n = int(input())
	a = input().split('W')
	f = True
	for i in a:
		if not help(i):
			f = False
			break
	if f:
		print('YES')
	else:
		print('NO')


import math

def solve():
	n = int(input())
	s = input()
	flag = 0
	for i in range(n):
		if s[i] == 'W':
			if flag == 1 or flag == 2:
				print('NO')
				return
			flag = 0
		elif s[i] == 'R':
			flag = flag | 1
		else:
			flag = flag | 2
	if flag == 1 or flag == 2:
		print('NO')
		return
	print('YES')
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	target = input()
	segments = target.split('W')
	for segment in segments:
		if not segment:
			continue
		if 'R' not in segment or 'B' not in segment:
			print('NO')
			break
	else:
		print('YES')


for _ in range(int(input())):
	N = int(input())
	S = input().split('W')
	for i in S:
		if i != '':
			if not ('R' in i and 'B' in i):
				print('NO')
				break
	else:
		print('YES')


from collections import defaultdict
t = int(input())

def solve():
	n = int(input())
	s = input()
	a = s.split('W')
	for i in a:
		if i == '':
			continue
		m = set(i)
		if len(m) < 2:
			print('NO')
			return
	print('YES')
for i in range(t):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	sp = s.split('W')
	check = True
	for part in sp:
		if len(part) == 0:
			continue
		if len(part) == 1:
			check = False
			break
		if 'B' not in part or 'R' not in part:
			check = False
			break
	if check:
		print('YES')
	else:
		print('NO')


for i in range(int(input())):
	n = int(input())
	l = input().split('W')
	ch = True
	for j in l:
		if len(j) > 0 and (j.count('B') == 0 or j.count('R') == 0):
			print('NO')
			ch = False
			break
	if ch:
		print('YES')


t = int(input())
for asdf in range(t):
	a = int(input())
	string = input()
	flag = True
	for s in string.split('W'):
		if s == '' or ('R' in s and 'B' in s):
			continue
		else:
			print('NO')
			flag = False
			break
	if flag:
		print('YES')


t = int(input())
for i in range(t):
	n = int(input())
	a = input().split('W')
	check = 1
	for i in a:
		if i != '':
			if ('R' in i and 'B' in i) == 0:
				check = 0
	if check == 1:
		print('YES')
	else:
		print('NO')


def task(n, s):
	s += 'W'
	B = False
	R = False
	for c in s:
		if c == 'W':
			if not B and R or (B and (not R)):
				print('NO')
				return
			else:
				B = False
				R = False
		elif c == 'B':
			B = True
		elif c == 'R':
			R = True
	print('YES')
t = int(input())
for i in range(0, t):
	n = int(input())
	s = input()
	task(n, s)


t = int(input())
for tt in range(t):
	n = int(input())
	s = input()
	found = False
	for i in s.split('W'):
		(r, b) = (0, 0)
		for j in i:
			if j == 'R':
				r += 1
			else:
				b += 1
		if r != 0 and b == 0 or (r == 0 and b != 0):
			print('NO')
			found = True
			break
	if not found:
		print('YES')


for _ in range(int(input())):
	n = int(input())
	s = input()
	rc = 0
	bc = 0
	flag = 0
	for i in s:
		if i == 'R':
			rc += 1
		elif i == 'B':
			bc += 1
		elif rc != 0 and bc == 0:
			print('NO')
			flag = 1
			break
		elif bc != 0 and rc == 0:
			print('NO')
			flag = 1
			break
		elif bc != 0 and rc != 0:
			bc = 0
			rc = 0
	if flag == 0 and (bc != 0 and rc != 0) or (bc == 0 and rc == 0):
		print('YES')
	elif flag == 0:
		print('NO')


for i in range(int(input())):
	n = int(input())
	a = input().split('W')
	for j in a:
		if ('R' not in j or 'B' not in j) and j != '':
			print('NO')
			break
	else:
		print('YES')


def allIsAll(s, m):
	for i in s:
		if i != m:
			return False
	return True
t = int(input())
for _ in range(t):
	l = int(input())
	s = input()
	p = s.split('W')
	flag = True
	for i in p:
		if i == '':
			continue
		if len(i) < 2:
			flag = False
			break
		elif allIsAll(i, 'R'):
			flag = False
			break
		elif allIsAll(i, 'B'):
			flag = False
			break
	if flag:
		print('YES')
	else:
		print('NO')


t = int(input())
for J in range(t):
	n = int(input())
	s = str(input())
	r = b = 0
	flag = 0
	for i in s:
		if i == 'W':
			if r * b == 0 and r + b > 0:
				flag = 1
				print('NO')
				break
			r = b = 0
		elif i == 'R':
			r += 1
		elif i == 'B':
			b += 1
	if r * b == 0 and r + b > 0 and (flag == 0):
		print('NO')
	elif flag == 0:
		print('YES')


def solve(pic):
	arr = pic.split('W')
	for a in arr:
		if not a:
			continue
		if len(a) == 1:
			return 'NO'
		elif 'R' not in a:
			return 'NO'
		elif 'B' not in a:
			return 'NO'
	return 'YES'
T = int(input())
for _ in range(T):
	l = int(input())
	picture = str(input())
	print(solve(picture))


t = int(input())
for i in range(t):
	flag = 0
	n = int(input())
	s = input()
	lst = s.split('W')
	R = 0
	B = 0
	for j in lst:
		if len(j) == 0:
			continue
		R = 0
		B = 0
		for k in j:
			if k == 'R':
				R += 1
			elif k == 'B':
				B += 1
		if R > 0 and B > 0:
			continue
		else:
			flag = 1
			break
	if flag == 0:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	l = input()
	r = 0
	b = 0
	flag = True
	for i in l:
		if i == 'R':
			r = 1
		elif i == 'B':
			b = 1
		elif i == 'W' and r == b:
			r = 0
			b = 0
		elif i == 'W' and r != b:
			flag = False
			break
	if flag and r == b:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	arr = s.strip('W').split('W')
	good = True
	for el in arr:
		if len(el) == 0:
			continue
		if len(el) == 1:
			good = False
			break
		if el == 'R' * len(el) or el == 'B' * len(el):
			good = False
			break
	if good:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	if 'W' not in s:
		if n == 1 or 'B' not in s or 'R' not in s:
			print('NO')
		else:
			print('YES')
		continue
	s = s.replace('W', ' ')
	ls = s.split()
	ans = 'YES'
	for a in ls:
		if len(a) == 1:
			ans = 'NO'
			break
		if 'B' not in a or 'R' not in a:
			ans = 'NO'
			break
	print(ans)