Alperen is standing at the point $(0,0)$. He is given a string $s$ of length $n$ and performs $n$ moves. The $i$-th move is as follows:

if $s_i = {L}$, then move one unit left;

if $s_i = {R}$, then move one unit right;

if $s_i = {U}$, then move one unit up;

if $s_i = {D}$, then move one unit down.

If Alperen starts at the center point, he can make the four moves shown.

There is a candy at $(1,1)$ (that is, one unit above and one unit to the right of Alperen's starting point). You need to determine if Alperen ever passes the candy.

Alperen's path in the first test case.


-----Input-----

The first line of the input contains an integer $t$ ($1 \leq t \leq 1000$) — the number of testcases.

The first line of each test case contains an integer $n$ ($1 \leq n \leq 50$) — the length of the string.

The second line of each test case contains a string $s$ of length $n$ consisting of characters ${L}$, ${R}$, ${D}$, and ${U}$, denoting the moves Alperen makes.


-----Output-----

For each test case, output "YES" (without quotes) if Alperen passes the candy, and "NO" (without quotes) 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
7
7
UUURDDL
2
UR
8
RRRUUDDD
3
LLL
4
DUUR
5
RUDLL
11
LLLLDDRUDRD
Output
YES
YES
NO
NO
YES
YES
NO


-----Note-----

In the first test case, Alperen follows the path $$(0,0) \overset{{U}}{\to} (0,1) \overset{{U}}{\to} (0,2) \overset{{U}}{\to} (0,3) \overset{{R}}{\to} (1,3) \overset{{D}}{\to} (1,2) \overset{{D}}{\to} \color{green}{\mathbf{(1,1)}} \overset{{L}}{\to} (0,1).$$ Note that Alperen doesn't need to end at the candy's location of $(1,1)$, he just needs to pass it at some point.

In the second test case, Alperen follows the path $$(0,0) \overset{{U}}{\to} (0,1) \overset{{R}}{\to} \color{green}{\mathbf{(1,1)}}.$$

In the third test case, Alperen follows the path $$(0,0) \overset{{R}}{\to} (1,0) \overset{{R}}{\to} (2,0) \overset{{R}}{\to} (3,0) \overset{{U}}{\to} (3,1) \overset{{U}}{\to} (3,2) \overset{{D}}{\to} (3,1) \overset{{D}}{\to} (3,0) \overset{{D}}{\to} (3,-1).$$

In the fourth test case, Alperen follows the path $$(0,0) \overset{{L}}{\to} (-1,0) \overset{{L}}{\to} (-2,0) \overset{{L}}{\to} (-3,0).$$

Difficulty: EASY

Solutions:
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	(candy_x, candy_y) = (1, 1)
	for move in s:
		if move == 'L':
			x -= 1
		elif move == 'R':
			x += 1
		elif move == 'U':
			y += 1
		elif move == 'D':
			y -= 1
		if x == candy_x and y == candy_y:
			print('YES')
			break
	else:
		print('NO')


def check(s):
	(x, y) = (0, 0)
	for i in s:
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) == (1, 1):
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	n = int(input())
	s = input()
	print(check(s))


import sys
input = sys.stdin.readline
T = int(input())
for _ in range(T):
	n = int(input())
	S = input().strip()
	x = 0
	y = 0
	check = False
	for i in range(n):
		if S[i] == 'L':
			x -= 1
		elif S[i] == 'U':
			y += 1
		elif S[i] == 'R':
			x += 1
		else:
			y -= 1
		if x == 1 and y == 1:
			check = True
			break
	if check:
		print('YES')
	else:
		print('NO')


import sys
t = int(sys.stdin.readline())
for _ in range(t):
	_ = sys.stdin.readline()
	s = sys.stdin.readline().strip()
	p = [0, 0]
	for c in s:
		if p == [1, 1]:
			break
		if c == 'U':
			p[1] += 1
		elif c == 'R':
			p[0] += 1
		elif c == 'L':
			p[0] -= 1
		elif c == 'D':
			p[1] -= 1
	print('YES' if p == [1, 1] else 'NO')


import sys

def in_int():
	return int(sys.stdin.readline())

def in_str():
	return sys.stdin.readline().rstrip()

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

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

def in_arr_str():
	return sys.stdin.readline().split()

def solve(s):
	c = [0, 0]
	for i in s:
		if i == 'U':
			c[1] += 1
		elif i == 'R':
			c[0] += 1
		elif i == 'L':
			c[0] -= 1
		elif i == 'D':
			c[1] -= 1
		if c == [1, 1]:
			return 'YES'
	return 'NO'

def main():
	t = in_int()
	for _ in range(t):
		_ = in_int()
		s = in_str()
		print(solve(s))
main()


size = int(input())
for _ in range(size):
	n = int(input())
	arr = input()
	(row, col) = (0, 0)
	ans = 'NO'
	for i in range(n):
		if row == 1 and col == 1:
			ans = 'YES'
			break
		if arr[i] == 'U':
			row += 1
		elif arr[i] == 'R':
			col += 1
		elif arr[i] == 'L':
			col -= 1
		else:
			row -= 1
	if row == 1 and col == 1:
		ans = 'YES'
	print(ans)


def check(p):
	l = [0, 0]
	for i in p:
		if i == 'L':
			l[0] = l[0] - 1
		elif i == 'R':
			l[0] = l[0] + 1
		elif i == 'U':
			l[1] = l[1] + 1
		elif i == 'D':
			l[1] = l[1] - 1
		if l == [1, 1]:
			return 1
		else:
			continue
	return 0
k = int(input())
q = []
for i in range(k):
	p = int(input())
	j = input()
	q.append(check(j))
for i in q:
	if i == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	strinp = input()
	(u, d, l, r) = (0, 0, 0, 0)
	yes = False
	for stri in strinp:
		if stri == 'U':
			u += 1
		if stri == 'D':
			d += 1
		if stri == 'L':
			l += 1
		if stri == 'R':
			r += 1
		if u - d == 1 and r - l == 1:
			yes = True
			break
	if yes:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	flag = False
	for i in s:
		if i == 'U':
			y += 1
		elif i == 'L':
			x -= 1
		elif i == 'D':
			y -= 1
		else:
			x += 1
		if x == 1 and y == 1:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	f = 0
	for i in s:
		if i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		elif i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		if x == 1 and y == 1:
			f = 1
			break
	if f == 1:
		print('YES')
	else:
		print('NO')


n = int(input())
c = []
for i in range(n):
	n2 = int(input())
	s = input()
	check = 0
	(x, y) = (0, 0)
	for k in s:
		if k == 'U':
			y += 1
		elif k == 'D':
			y -= 1
		elif k == 'L':
			x -= 1
		elif k == 'R':
			x += 1
		if x == 1 and y == 1:
			check = 1
			break
	if check == 1:
		c.append('YES')
	else:
		c.append('NO')
for mm in c:
	print(mm, end='\n')


t = int(input())
lst = []
if 1 <= t and t <= 1000:
	for i_01 in range(0, t):
		tv = 0
		x = 0
		y = 0
		n = int(input())
		s = str(input())
		if len(s) == n and s.count('L') + s.count('R') + s.count('U') + s.count('D') == n:
			for i_11 in range(0, n):
				if s[i_11] == 'L':
					x -= 1
				elif s[i_11] == 'R':
					x += 1
				elif s[i_11] == 'U':
					y += 1
				elif s[i_11] == 'D':
					y -= 1
				if x == 1 and y == 1:
					tv = 1
					break
		if tv == 1:
			lst.append('YES')
		else:
			lst.append('NO')
	for i in range(0, t):
		print(lst[i])


t = int(input())
while t:
	n = int(input())
	s = input()
	(u, r, k) = (0, 0, 0)
	for i in s:
		if i == 'U':
			u += 1
		elif i == 'D':
			u -= 1
		elif i == 'R':
			r += 1
		elif i == 'L':
			r -= 1
		if u == 1 and r == 1:
			k = 1
			print('YES')
			break
	if k != 1:
		print('NO')
	t -= 1


for i in range(int(input())):
	num = int(input())
	res = list(input())
	x = 0
	y = 0
	ans = 0
	for j in res:
		if j == 'U':
			y += 1
		elif j == 'R':
			x += 1
		elif j == 'L':
			x -= 1
		else:
			y -= 1
		if x == 1 and y == 1:
			print('YES')
			ans = 1
			break
	if ans == 0:
		print('NO')


t = int(input())
for i in range(t):
	k = int(input())
	s = input()
	x = 0
	y = 0
	for l in s:
		if l == 'U':
			y += 1
		elif l == 'D':
			y -= 1
		elif l == 'R':
			x += 1
		elif l == 'L':
			x -= 1
		if x == 1 and y == 1:
			print('YES')
			break
	else:
		print('NO')


N_bags = int(input())
resp = ''
dic_move = {'R': [1, 0], 'L': [-1, 0], 'U': [0, 1], 'D': [0, -1]}
for i in range(N_bags):
	cords = [0, 0]
	N = int(input())
	command = input()
	for step in command:
		cords[0] += dic_move[step][0]
		cords[1] += dic_move[step][1]
		if cords[0] == 1 and cords[1] == 1:
			resp += 'YES\n'
			break
	else:
		resp += 'NO\n'
print(resp)


def fnc(n, a):
	x = 0
	y = 0
	for i in range(n):
		if a[i] == 'L':
			x = x - 1
		elif a[i] == 'R':
			x = x + 1
		elif a[i] == 'U':
			y = y + 1
		elif a[i] == 'D':
			y = y - 1
		if x == 1 and y == 1:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	print(fnc(n, a))


def main():
	for t in range(int(input())):
		n = int(input())
		s = input()
		a = b = 0
		flag = False
		for i in range(n):
			if s[i] == 'U':
				b += 1
			elif s[i] == 'D':
				b -= 1
			elif s[i] == 'L':
				a -= 1
			else:
				a += 1
			if a == 1 and b == 1:
				print('YES')
				flag = True
				break
		if not flag:
			print('NO')
main()


for j in range(int(input())):
	b = int(input())
	a = str(input())
	x = 0
	y = 0
	z = 0
	for i in range(b):
		if a[i] == 'U':
			y += 1
		elif a[i] == 'R':
			x += 1
		elif a[i] == 'D':
			y -= 1
		elif a[i] == 'L':
			x -= 1
		if x == 1 and y == 1:
			z = 1
			break
	if z == 1:
		print('YES')
	else:
		print('NO')


a = int(input(''))
for j in range(a):
	F = int(input(''))
	b = input('').lower()
	d = 0
	list = [0, 0]
	for i in b:
		if i == 'l':
			list[0] = list[0] - 1
		elif i == 'r':
			list[0] = list[0] + 1
		elif i == 'u':
			list[1] = list[1] + 1
		elif i == 'd':
			list[1] = list[1] - 1
		if list == [1, 1]:
			d += 1
	if d > 0:
		print('YES')
	else:
		print('NO')


T = int(input())
x = 0
y = 0
s = ''
for i in range(T):
	n = int(input())
	a = input()
	for j in a:
		if j == 'U':
			y = y + 1
		elif j == 'D':
			y = y - 1
		elif j == 'R':
			x = x + 1
		elif j == 'L':
			x = x - 1
		if x == 1 and y == 1:
			s = 'YES'
			break
		else:
			continue
	if s == 'YES':
		print('YES')
	else:
		print('NO')
	s = ''
	x = 0
	y = 0


m = int(input())
x = 0
y = 0
p = False
for i in range(m):
	n = int(input())
	s = input()
	p = False
	x = 0
	y = 0
	for j in s:
		if j == 'U':
			y += 1
		elif j == 'R':
			x += 1
		elif j == 'D':
			y -= 1
		else:
			x -= 1
		if x == 1 and y == 1:
			p = True
			break
	if p:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	instructions = list(input())
	(x, y) = (0, 0)
	state = 0
	for instruction in instructions:
		if instruction == 'L':
			x -= 1
		elif instruction == 'R':
			x += 1
		elif instruction == 'U':
			y += 1
		elif instruction == 'D':
			y -= 1
		if (x, y) == (1, 1):
			state = 1
			break
	if state:
		print('YES')
	else:
		print('NO')


def kek(s, n: int):
	c = [0, 0]
	for j in range(n):
		if s[j] == 'L':
			c[0] -= 1
		elif s[j] == 'R':
			c[0] += 1
		elif s[j] == 'U':
			c[1] += 1
		elif s[j] == 'D':
			c[1] -= 1
		if c == [1, 1]:
			return 'YES'
	return 'NO'
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	print(kek(s, n))


def solve():
	n = int(input().strip())
	s = input().strip()
	(x, y) = (0, 0)
	for i in s:
		if i == 'U':
			y += 1
		if i == 'L':
			x -= 1
		if i == 'D':
			y -= 1
		if i == 'R':
			x += 1
		if x == 1 and y == 1:
			print('YES')
			return
	print('NO')
t = int(input().strip())
for _ in range(t):
	solve()


for i in range(int(input())):
	x = int(input())
	aux = input()
	ver = 0
	hor = 0
	doc = False
	for j in aux:
		if j == 'L':
			hor -= 1
		elif j == 'R':
			hor += 1
		elif j == 'U':
			ver += 1
		else:
			ver -= 1
		if ver == 1 and hor == 1:
			doc = True
	if doc:
		print('YES')
	else:
		print('NO')


inputs = int(input())
positionx = 0
positiony = 0
found = False
for i in range(inputs):
	size = int(input())
	c = input()
	n = len(c)
	for j in range(n):
		if c[j] == 'U':
			positiony += 1
		if c[j] == 'D':
			positiony -= 1
		if c[j] == 'R':
			positionx += 1
		if c[j] == 'L':
			positionx -= 1
		if positionx == 1 and positiony == 1:
			print('YES')
			found = True
			break
	if not found:
		print('NO')
	found = False
	positionx = 0
	positiony = 0


t = int(input())
while t != 0:
	length = input()
	text = input().lower()
	u = 0
	r = 0
	breakindex = None
	for i in text:
		if i == 'u':
			u += 1
		elif i == 'd':
			u -= 1
		elif i == 'r':
			r += 1
		elif i == 'l':
			r -= 1
		if u == 1 and r == 1:
			print('YES')
			breakindex = 1
			break
	if breakindex is None:
		print('NO')
	t -= 1


import sys
input_file = sys.stdin
directions = {'U': (0, 1), 'R': (1, 0), 'L': (-1, 0), 'D': (0, -1)}
for i in input_file:
	position = (0, 0)
	if i.strip().isalpha():
		for x in i.strip():
			position = (position[0] + directions[x][0], position[1] + directions[x][1])
			if position == (1, 1):
				break
		if position == (1, 1):
			sys.stdout.write('YES\n')
		else:
			sys.stdout.write('NO\n')


n = int(input())
for i in range(n):
	num = int(input())
	str = input()

	def sol(num, str):
		u = 0
		r = 0
		for i in str:
			if i == 'U':
				u += 1
			elif i == 'R':
				r += 1
			elif i == 'D':
				u -= 1
			elif i == 'L':
				r -= 1
			if r == u == 1:
				return 'YES'
		return 'NO'
	print(sol(num, str))


def lll(r, u):
	y = 0
	o = 0
	flag = 0
	for w in range(len(u)):
		if u[w] == 'U':
			y = y + 1
		elif u[w] == 'R':
			o = o + 1
		elif u[w] == 'D':
			y = y - 1
		else:
			o = o - 1
		if y == 1 and o == 1:
			flag = 1
			break
	if flag == 1:
		return 'YES'
	else:
		return 'NO'
t = int(input())
for i in range(t):
	n = int(input())
	m = input()
	print(lll(n, m))


testcases = int(input())
o = []
for _ in range(testcases):
	found = False
	currentPT = [0, 0]
	seriesLen = int(input())
	series = input()
	for i in range(seriesLen):
		if series[i] == 'U':
			currentPT[1] += 1
		elif series[i] == 'R':
			currentPT[0] += 1
		elif series[i] == 'D':
			currentPT[1] -= 1
		elif series[i] == 'L':
			currentPT[0] -= 1
		if currentPT[0] == 1 and currentPT[1] == 1:
			found = True
			break
	if found:
		o.append('YES')
	else:
		o.append('NO')
for item in o:
	print(item)


import sys
lines = list(map(str.strip, sys.stdin.readlines()))
for line in lines[2::2]:
	moves = line
	(x, y) = (0, 0)
	visited = set()
	for move in moves:
		if move == 'U':
			y += 1
		elif move == 'D':
			y -= 1
		elif move == 'L':
			x -= 1
		elif move == 'R':
			x += 1
		visited.add((x, y))
	print('YES' if (1, 1) in visited else 'NO')


for asd in range(int(input())):
	n = int(input())
	x = y = 0
	for i in input():
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		if x == y == 1:
			print('YES')
			break
	else:
		print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = 0
	y = 0
	ans = 'NO'
	for char in s:
		if char == 'U':
			y += 1
		elif char == 'D':
			y -= 1
		elif char == 'R':
			x += 1
		elif char == 'L':
			x -= 1
		if x == y == 1:
			ans = 'YES'
			break
	print(ans)


t = int(input())
for t in range(t):
	n = int(input())
	s1 = input()
	s = ''
	k = 0
	for i in range(n):
		s += s1[i]
		if s.count('R') - s.count('L') == 1:
			if s.count('U') - s.count('D') == 1:
				k += 1
				break
	if k > 0:
		print('YES')
	else:
		print('NO')


t = int(input())
while t:
	n = int(input())
	s = input()
	x = 0
	y = 0
	f = 0
	for i in s:
		if i == 'R':
			x += 1
		elif i == 'L':
			x -= 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		if x == 1 and y == 1:
			f = 1
			break
	if f == 1:
		print('YES')
	else:
		print('NO')
	t = t - 1


for _ in range(int(input())):
	a = int(input())
	x = 0
	y = 0
	s = input()
	k = 0
	for i in s:
		if x == 1 and y == 1:
			k = 1
			break
		if i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		elif i == 'R':
			x += 1
		else:
			x -= 1
	if x == 1 and y == 1:
		k = 1
	if k == 1:
		print('YES')
	else:
		print('NO')


test = int(input())
for _ in range(test):
	length = int(input())
	moves = list(input())
	x = 0
	y = 0
	ans = 'NO'
	for move in moves:
		if move == 'U':
			y += 1
		elif move == 'D':
			y -= 1
		elif move == 'R':
			x += 1
		elif move == 'L':
			x -= 1
		if x == 1 and y == 1:
			ans = 'YES'
			break
	print(ans)


t = int(input())
res = []
for _ in range(t):
	n = int(input())
	s = input()
	ans = 'NO'
	x = 0
	y = 0
	for c in s:
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		if (x, y) == (1, 1):
			ans = 'YES'
			break
	res.append(ans)
for i in res:
	print(i)


inputs = []
for i in range(int(input())):
	input()
	inputs.append(input())
posnum = {'L': -1, 'R': 1, 'U': 1, 'D': -1}
for inp in inputs:
	initpos = [0, 0]
	flag = False
	for char in inp:
		if char in ['L', 'R']:
			initpos[0] += posnum[char]
		else:
			initpos[1] += posnum[char]
		if initpos == [1, 1]:
			flag = True
			break
	print('YES' if flag else 'NO')


tc = int(input())
for i in range(tc):
	n = int(input())
	x = 0
	y = 0
	s = input()
	ans = 'NO'
	for i in s:
		if i == 'U':
			y += 1
		elif i == 'R':
			x += 1
		elif i == 'D':
			y -= 1
		else:
			x -= 1
		if x == 1 and y == 1:
			ans = 'YES'
	print(ans)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	ans = False
	start = [0, 0]
	for j in range(n):
		if s[j] == 'L':
			start[0] -= 1
		elif s[j] == 'R':
			start[0] += 1
		elif s[j] == 'U':
			start[1] += 1
		elif s[j] == 'D':
			start[1] -= 1
		if start == [1, 1]:
			ans = True
			break
	if ans:
		print('YES')
	else:
		print('NO')


n = int(input())
res = []
for i in range(n):
	k = int(input())
	s = input()
	pos = [0, 0]
	for symb in s:
		found = False
		if symb == 'D':
			pos[1] -= 1
		elif symb == 'U':
			pos[1] += 1
		elif symb == 'L':
			pos[0] -= 1
		elif symb == 'R':
			pos[0] += 1
		if pos == [1, 1]:
			res.append('YES')
			found = True
			break
	if found == False:
		res.append('NO')
for item in res:
	print(item)


t = int(input())
for i in range(t):
	n = int(input())
	l = list(input())
	x = 0
	y = 0
	for d in l:
		if d == 'U':
			y += 1
		elif d == 'D':
			y -= 1
		elif d == 'R':
			x += 1
		else:
			x -= 1
		if x == 1 and y == 1:
			print('YES')
			break
	else:
		print('NO')


rng = int(input())

def calc(s, n):
	arr = [0, 0]
	candy = [1, 1]
	for char in s:
		if char == 'U':
			arr[1] += 1
		elif char == 'R':
			arr[0] += 1
		elif char == 'L':
			arr[0] -= 1
		else:
			arr[1] -= 1
		if arr == candy:
			print('YES')
			return
	print('NO')
for i in range(rng):
	n = int(input())
	s = input()
	calc(s, n)


tc = int(input())
res = []
for i in range(tc):
	n = int(input())
	st = input()
	point = [0, 0]
	flag = 0
	for i in st:
		if i == 'U':
			point[1] += 1
		elif i == 'D':
			point[1] -= 1
		elif i == 'L':
			point[0] -= 1
		elif i == 'R':
			point[0] += 1
		if point[0] == 1 and point[1] == 1:
			flag = 1
			res.append('YES')
			break
	if flag == 0:
		res.append('NO')
for i in res:
	print(i)


t = int(input())
for i in range(t):
	n = int(input())
	c = input()
	c = list(c)
	h = 0
	v = 0
	m = 0
	for j in c:
		if j == 'L':
			h -= 1
		elif j == 'R':
			h += 1
		elif j == 'U':
			v += 1
		elif j == 'D':
			v -= 1
		if h == 1 and v == 1:
			m = 1
			break
	if m == 1:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	x = y = 0
	lth = int(input())
	command = input()
	flag = False
	for ch in command:
		if ch == 'U':
			y += 1
		elif ch == 'D':
			y -= 1
		elif ch == 'L':
			x -= 1
		elif ch == 'R':
			x += 1
		if x == y == 1:
			flag = True
			break
	if flag:
		print('YES')
	else:
		print('NO')


tt = int(input())
while tt:
	n = int(input())
	a = input()
	x = 0
	y = 0
	flag = 'NO'
	for i in a:
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		if x == 1 and y == 1:
			flag = 'YES'
			break
	print(flag)
	tt -= 1


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	f = 0
	for j in s:
		if j == 'U':
			y += 1
		if j == 'D':
			y -= 1
		if j == 'R':
			x += 1
		if j == 'L':
			x -= 1
		if x == 1 and y == 1:
			f = 1
	if f == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for i in range(t):
	n1 = int(input())
	n = input()
	s = [0, 0]
	for j in n:
		if j == 'L':
			s[0] -= 1
		elif j == 'R':
			s[0] += 1
		elif j == 'U':
			s[1] += 1
		else:
			s[1] -= 1
		if s == [1, 1]:
			print('YES')
			break
	else:
		print('NO')


for t in range(int(input())):
	n = int(input())
	s = input()
	a = [0, 0]
	f = 0
	for i in s:
		if i == 'D':
			a[1] -= 1
		elif i == 'U':
			a[1] += 1
		elif i == 'L':
			a[0] -= 1
		else:
			a[0] += 1
		if a == [1, 1]:
			f = 1
			break
	if f:
		print('YES')
	else:
		print('NO')


def solve():
	n = int(input())
	s = str(input())
	a = [0, 0]
	for i in range(n):
		if s[i] == 'U':
			a[1] += 1
		elif s[i] == 'R':
			a[0] += 1
		elif s[i] == 'D':
			a[1] -= 1
		elif s[i] == 'L':
			a[0] -= 1
		if a[0] == 1 and a[1] == 1:
			print('YES')
			return
	print('NO')
t = int(input())
for i in range(t):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	(a, b, flag) = (0, 0, 0)
	for x in s:
		if x == 'U':
			b += 1
		elif x == 'R':
			a += 1
		elif x == 'D':
			b -= 1
		else:
			a -= 1
		if a == 1 and b == 1:
			flag = 1
			break
	if flag == 1:
		print('YES')
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = [0, 0]
	for i in range(len(s)):
		if s[i] == 'U':
			l[1] += 1
			if l == [1, 1]:
				print('YES')
				break
		if s[i] == 'R':
			l[0] += 1
			if l == [1, 1]:
				print('YES')
				break
		if s[i] == 'D':
			l[1] -= 1
			if l == [1, 1]:
				print('YES')
				break
		if s[i] == 'L':
			l[0] -= 1
			if l == [1, 1]:
				print('YES')
				break
	else:
		print('NO')


t = int(input())
for _ in range(t):
	n = int(input())
	directions = input()
	(x, y) = (0, 0)
	cond = False
	for d in directions:
		if d == 'L':
			x -= 1
		elif d == 'R':
			x += 1
		elif d == 'U':
			y += 1
		else:
			y -= 1
		if x == 1 and y == 1:
			print('YES')
			cond = True
			break
	if not cond:
		print('NO')


t = int(input())
dictionary = {'U': 1j, 'D': -1j, 'L': -1, 'R': 1}

def ans(s):
	current = 0 + 0j
	for direction in s:
		current += dictionary[direction]
		if current == 1 + 1j:
			return 'YES'
	return 'NO'
for _ in range(t):
	n = int(input())
	s = list(input())
	print(ans(s))


z = int(input())
for q in range(z):
	n = int(input())
	s = input()
	l = [0, 0]
	flag = 0
	for i in s:
		if i == 'R':
			l[0] += 1
		elif i == 'L':
			l[0] -= 1
		elif i == 'U':
			l[1] += 1
		else:
			l[1] -= 1
		if l == [1, 1]:
			flag = 1
			break
	if flag:
		print('YES')
	else:
		print('NO')


for _ in range(int(input())):
	start = [0, 0]
	length = int(input())
	move = input()
	for dir in move:
		if dir == 'U':
			start[1] += 1
		elif dir == 'D':
			start[1] -= 1
		elif dir == 'L':
			start[0] -= 1
		elif dir == 'R':
			start[0] += 1
		if start == [1, 1]:
			print('YES')
			break
	else:
		print('NO')


def sol(n, s):
	(i, j) = (0, 0)
	for k in s:
		if k == 'D':
			i -= 1
		elif k == 'U':
			i += 1
		elif k == 'R':
			j += 1
		else:
			j -= 1
		if i == 1 and j == 1:
			return 'YES'
	return 'NO'
for _ in range(int(input())):
	n = int(input())
	s = input()
	print(sol(n, s))


for _ in range(int(input())):
	n = int(input())
	s = input()
	right = 0
	up = 0
	ans = 0
	for c in s:
		if c == 'U':
			up += 1
		elif c == 'D':
			up -= 1
		elif c == 'L':
			right -= 1
		elif c == 'R':
			right += 1
		else:
			pass
		if right == 1 and up == 1:
			ans = 1
			break
	if ans:
		print('YES')
	else:
		print('NO')


def alp(s):
	k = [0, 0]
	for i in s:
		if i == 'L':
			k[0] -= 1
		elif i == 'U':
			k[1] += 1
		elif i == 'R':
			k[0] += 1
		else:
			k[1] -= 1
		if k == [1, 1]:
			return 'YES'
	return 'NO'
t = int(input())
a = []
for i in range(t):
	n = int(input())
	s = input()
	a.append(alp(s))
for i in a:
	print(i)


def li():
	return list(map(int, input().split()))
for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (1, 1)
	(i, j) = (0, 0)
	for c in s:
		if c == 'U':
			i += 1
		elif c == 'D':
			i -= 1
		elif c == 'L':
			j -= 1
		else:
			j += 1
		if i == x and j == y:
			print('YES')
			break
	else:
		print('NO')


i = int(input())
for d in range(i):
	j = input()
	j = input()
	alap = [0, 0]
	y = 'NO'
	for k in j:
		if k == 'U':
			alap[1] = alap[1] + 1
			if alap == [1, 1]:
				y = 'YES'
		elif k == 'D':
			alap[1] = alap[1] - 1
			if alap == [1, 1]:
				y = 'YES'
		elif k == 'R':
			alap[0] = alap[0] + 1
			if alap == [1, 1]:
				y = 'YES'
		else:
			alap[0] = alap[0] - 1
			if alap == [1, 1]:
				y = 'YES'
	print(y)


n = int(input())
ll = []
for i in range(n):
	input()
	ll.append(input())
coord = [0, 0]
t = True
for map in ll:
	for side in map:
		if 'U' == side:
			coord[1] += 1
		elif 'R' == side:
			coord[0] += 1
		elif 'L' == side:
			coord[0] -= 1
		else:
			coord[1] -= 1
		if coord[0] == 1 and coord[1] == 1:
			print('YES')
			t = False
			break
	coord = [0, 0]
	if t:
		print('NO')
	t = True


inputs_num = int(input())
for i in range(inputs_num):
	steps_num = int(input())
	steps = input()
	x = 0
	y = 0
	res = False
	for step in steps:
		if step == 'U':
			y += 1
		elif step == 'D':
			y -= 1
		elif step == 'L':
			x -= 1
		else:
			x += 1
		if x == 1 and y == 1:
			res = True
			break
	if res:
		print('YES')
	else:
		print('NO')


n = int(input())
for i in range(n):
	l = [0, 0]
	num = int(input())
	s = input()
	f = True
	for j in s:
		if j == 'U':
			l[1] += 1
		if j == 'D':
			l[1] -= 1
		if j[0] == 'L':
			l[0] -= 1
		if j[0] == 'R':
			l[0] += 1
		if l[0] == 1 and l[1] == 1:
			f = True
			break
		else:
			f = False
	if f == True:
		print('YES')
	else:
		print('NO')


from collections import Counter
t = int(input())
while t:
	n = int(input())
	c = str(input())
	x = y = 0
	for i in c:
		if i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		elif i == 'R':
			x += 1
		else:
			x -= 1
		if x == 1 and y == 1:
			print('YES')
			break
	else:
		print('NO')
	t -= 1


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = 0
	r = 0
	ok = 0
	for i in range(n):
		if s[i] == 'U':
			r += 1
		elif s[i] == 'D':
			r -= 1
		elif s[i] == 'R':
			l += 1
		else:
			l -= 1
		if l == 1 and r == 1:
			ok = 1
			break
	print('YES' if ok == 1 else 'NO')


n = int(input())
for i in range(n):
	a = int(input())
	b = input()
	x = 0
	y = 0
	for i in range(a):
		if b[i] == 'U':
			y += 1
		elif b[i] == 'D':
			y -= 1
		elif b[i] == 'R':
			x += 1
		else:
			x -= 1
		if x == 1 and y == 1:
			print('YES')
			break
		if i == a - 1:
			print('NO')


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	k = False
	for i in s:
		if i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		elif i == 'R':
			x += 1
		else:
			x -= 1
		if x == y == 1:
			k = True
	print(['NO', 'YES'][k])