Read problems statements in [Mandarin Chinese],[Vietnamese], and [Bengali] as well.

Today is Chef's birthday and he is looking forward to his gift. As usual, the gift is hidden and Chef has to follow a sequence of $N$ instructions to reach it.

Initially, Chef is standing in the cell $(0, 0)$ of a two-dimensional grid. The sequence of instructions is given as a string $S$. If we denote Chef's current cell by $(x, y)$, each character of $S$ corresponds to an instruction as follows:
'L' means to go left, i.e. to the cell $(x-1, y)$
'R' means to go right, i.e. to the cell $(x+1, y)$
'U' means to go up, i.e. to the cell $(x, y+1)$
'D' means to go down, i.e. to the cell $(x, y-1)$

In addition, Chef should never perform multiple consecutive moves along the same axis of the grid. If there are multiple consecutive instructions to move along the same axis (left/right or up/down), he should perform only the first of these moves.

Find the cell $(x_{g}, y_{g})$ which contains the hidden gift.

------  Input ------
The first line of the input contains a single integer $T$ denoting the number of test cases. The description of $T$ test cases follows.
The first line of each test case contains a single integer $N$.
The second line contains a single string $S$ with length $N$.

------  Output ------
For each test case, print a single line containing two space-separated integers $x_{g}$ and $y_{g}$.

------  Constraints ------
$1 ≤ T ≤ 100$
$1 ≤ N ≤ 1,000$
$S$ contains only characters 'L', 'R', 'U' and 'D'

----- Sample Input 1 ------ 
3

5

LLLUR

7

LLLRUUD

8

LRULLUDU
----- Sample Output 1 ------ 
0 1

-1 1

-2 2
----- explanation 1 ------ 
Example case 1: Chef's path is $(0,0) \rightarrow (-1,0) \rightarrow (-1,0) \rightarrow (-1,0) \rightarrow (-1,1) \rightarrow (0,1)$.

Difficulty: EASY

Solutions:
for j in range(int(input())):
	n = int(input())
	a = list(input())
	(x, y) = (0, 0)
	p = ''
	for i in range(len(a)):
		if a[i] == 'L' and p != 'L' and (p != 'R'):
			p = 'L'
			x = x - 1
		elif a[i] == 'U' and p != 'U' and (p != 'D'):
			p = 'U'
			y = y + 1
		elif a[i] == 'D' and p != 'U' and (p != 'D'):
			p = 'D'
			y = y - 1
		elif a[i] == 'R' and p != 'L' and (p != 'R'):
			p = 'R'
			x = x + 1
	print(x, y)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	next_step = ''
	x = 0
	y = 0
	for i in range(n):
		if s[i] in ['L', 'R'] and next_step not in ['L', 'R'] or (s[i] in ['U', 'D'] and next_step not in ['U', 'D']):
			next_step = s[i]
			if next_step == 'L':
				x -= 1
			elif next_step == 'R':
				x += 1
			elif next_step == 'U':
				y += 1
			else:
				y -= 1
		else:
			pass
	print(x, y)


for me in range(int(input())):
	n = int(input())
	s = input()
	pos = [0, 0]
	prev = ''
	for l in s:
		if l == 'R' or l == 'L':
			if prev == 'R' or prev == 'L':
				continue
			elif l == 'R':
				pos[0] += 1
			else:
				pos[0] -= 1
		elif l == 'U' or l == 'D':
			if prev == 'U' or prev == 'D':
				continue
			elif l == 'U':
				pos[1] += 1
			else:
				pos[1] -= 1
		prev = l
	print(*pos)


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


def solve():
	global x_cord, y_cord
	x_cord = 0
	y_cord = 0
	x = True
	y = True
	for i in s:
		if x:
			if i == 'L':
				x_cord += -1
				y = True
				x = False
			elif i == 'R':
				x_cord += 1
				y = True
				x = False
		if y:
			if i == 'U':
				y_cord += 1
				x = True
				y = False
			elif i == 'D':
				y_cord += -1
				x = True
				y = False
	print(x_cord, y_cord)
for _ in range(int(input())):
	n = int(input())
	s = input()
	solve()


t = int(input())
for tc in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	a = ''
	for j in s:
		if j == 'L' and (a != 'L' and a != 'R'):
			x = x - 1
			a = j
		elif j == 'R' and (a != 'L' and a != 'R'):
			x = x + 1
			a = j
		elif j == 'U' and (a != 'D' and a != 'U'):
			y = y + 1
			a = j
		elif j == 'D' and (a != 'D' and a != 'U'):
			y = y - 1
			a = j
	print(x, y)


for t in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	xa = 0
	ya = 0
	for letter in s:
		if xa == 1 and letter == 'L' or (xa == 1 and letter == 'R'):
			continue
		elif ya == 1 and letter == 'U' or (ya == 1 and letter == 'D'):
			continue
		elif letter == 'L':
			xa = 1
			ya = 0
			x -= 1
		elif letter == 'R':
			xa = 1
			ya = 0
			x += 1
		elif letter == 'U':
			xa = 0
			ya = 1
			y += 1
		else:
			xa = 0
			ya = 1
			y -= 1
	print(x, y)


for i in range(int(input())):
	n = int(input())
	x = 0
	y = 0
	str_ = input()
	temp = ''
	for j in str_:
		if j == 'L' and (temp != 'L' and temp != 'R'):
			x -= 1
			temp = 'L'
		elif j == 'R' and (temp != 'R' and temp != 'L'):
			x += 1
			temp = 'R'
		elif j == 'U' and (temp != 'U' and temp != 'D'):
			y += 1
			temp = 'U'
		elif j == 'D' and (temp != 'D' and temp != 'U'):
			y -= 1
			temp = 'D'
	print(x, y)


for _ in range(int(input())):
	l = int(input())
	s = input()
	x = 0
	y = 0
	c = 3
	for i in range(l):
		if s[i] in {'L', 'R'}:
			if c != 1:
				if s[i] == 'L':
					x -= 1
					c = 1
				else:
					x += 1
					c = 1
		elif s[i] in {'U', 'D'}:
			if c != 0:
				if s[i] == 'U':
					y += 1
					c = 0
				else:
					y -= 1
					c = 0
	print(x, y)


for _ in range(int(input())):
	n = int(input())
	s = input()
	prev = ''
	coordi = [0, 0]
	for i in s:
		if i == 'L' or i == 'R':
			if prev != 'L' and prev != 'R':
				if i == 'L':
					coordi[0] -= 1
				elif i == 'R':
					coordi[0] += 1
		elif i == 'U' or i == 'D':
			if prev != 'U' and prev != 'D':
				if i == 'U':
					coordi[1] += 1
				elif i == 'D':
					coordi[1] -= 1
		prev = i
	print(coordi[0], coordi[1])


t = int(input())
for i in range(t):
	n = int(input())
	s = list(input())
	l1 = []
	x = 0
	y = 0
	temp = ''
	for i in s:
		if i == 'L' and (temp != 'L' and temp != 'R'):
			x = x - 1
			temp = i
		elif i == 'R' and (temp != 'L' and temp != 'R'):
			x = x + 1
			temp = i
		elif i == 'U' and (temp != 'D' and temp != 'U'):
			y = y + 1
			temp = i
		elif i == 'D' and (temp != 'D' and temp != 'U'):
			y = y - 1
			temp = i
	print(x, y)


for t in range(int(input())):
	input()
	x = 0
	y = 0
	s = input()
	cu = None
	for i in s:
		if i == 'U':
			if cu is None or cu == 'LR':
				cu = 'UD'
				y += 1
		elif i == 'D':
			if cu is None or cu == 'LR':
				cu = 'UD'
				y -= 1
		elif i == 'R':
			if cu is None or cu == 'UD':
				cu = 'LR'
				x += 1
		elif i == 'L':
			if cu is None or cu == 'UD':
				cu = 'LR'
				x -= 1
	print(x, y)


for i in range(int(input())):
	n = int(input())
	s = input()
	previous_x = False
	previous_y = False
	x = 0
	y = 0
	for i in s:
		if (i == 'L' or i == 'R') and (not previous_x):
			previous_x = True
			previous_y = False
			if i == 'L':
				x -= 1
			else:
				x += 1
		elif (i == 'U' or i == 'D') and (not previous_y):
			previous_y = True
			previous_x = False
			if i == 'U':
				y += 1
			else:
				y -= 1
	print(x, y)


def main():
	t = int(input())
	while t:
		x = 0
		y = 0
		n = int(input())
		st = input()
		cc = ''
		if st[0] == 'L':
			x -= 1
			cc = 'L'
		elif st[0] == 'R':
			x += 1
			cc = 'R'
		elif st[0] == 'U':
			y += 1
			cc = 'U'
		else:
			y -= 1
			cc = 'D'
		for i in range(1, n):
			if cc == 'L' or cc == 'R':
				if st[i] == 'U':
					y += 1
					cc = 'U'
				elif st[i] == 'D':
					y -= 1
					cc = 'D'
			elif st[i] == 'L':
				x -= 1
				cc = 'L'
			elif st[i] == 'R':
				x += 1
				cc = 'R'
		print(x, y)
		t = t - 1
main()


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	u = 0
	for i in range(len(s)):
		if s[i] == 'L' and u != 1:
			x -= 1
			u = 1
		elif s[i] == 'R' and u != 1:
			x += 1
			u = 1
		elif s[i] == 'U' and u != 2:
			y += 1
			u = 2
		elif s[i] == 'D' and u != 2:
			y -= 1
			u = 2
	print(x, y)


for i in range(int(input())):
	n = int(input())
	a = list(input())
	d = []
	d.append(a[0])
	for j in a:
		if d[-1] != j:
			if d[-1] == 'L' and j != 'R':
				d.append(j)
			elif d[-1] == 'R' and j != 'L':
				d.append(j)
			elif d[-1] == 'U' and j != 'D':
				d.append(j)
			elif d[-1] == 'D' and j != 'U':
				d.append(j)
	a = d
	(x, y) = (0, 0)
	for j in a:
		if j == 'R':
			x += 1
		elif j == 'L':
			x -= 1
		elif j == 'U':
			y += 1
		elif j == 'D':
			y -= 1
	print(x, y)


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


T = int(input())
for i in range(T):
	N = int(input())
	S = input()
	(x, y) = (0, 0)
	l = 0
	for i in range(N):
		if S[i] == 'L' and l != 1:
			x -= 1
			l = 1
		elif S[i] == 'R' and l != 1:
			x += 1
			l = 1
		elif S[i] == 'U' and l != 2:
			y += 1
			l = 2
		elif S[i] == 'D' and l != 2:
			y -= 1
			l = 2
	print(x, y)


T = int(input())
for m in range(T):
	x = 0
	y = 0
	n = int(input())
	s = input()
	for i in range(n):
		if i > 0:
			if not ((s[i] == 'R' or s[i] == 'L') and (s[i - 1] == 'R' or s[i - 1] == 'L') or ((s[i] == 'U' or s[i] == 'D') and (s[i - 1] == 'U' or s[i - 1] == 'D'))):
				if s[i] == 'L':
					x -= 1
				elif s[i] == 'R':
					x += 1
				elif s[i] == 'U':
					y += 1
				else:
					y -= 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
	print(str(x) + ' ' + str(y))


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	d = list(s)
	v = []
	for i in range(len(d) - 1):
		if d[i + 1] == d[i]:
			v.append(i + 1)
		elif d[i + 1] == 'R' and d[i] == 'L' or (d[i] == 'R' and d[i + 1] == 'L'):
			v.append(i + 1)
		elif d[i + 1] == 'U' and d[i] == 'D' or (d[i] == 'U' and d[i + 1] == 'D'):
			v.append(i + 1)
	d.pop(v[0])
	for i in range(1, len(v)):
		d.pop(v[i] - i)
	a = 0
	b = 0
	for i in range(len(d)):
		if d[i] == 'L':
			a -= 1
		elif d[i] == 'R':
			a += 1
		elif d[i] == 'U':
			b += 1
		elif d[i] == 'D':
			b -= 1
	print(a, b)


for _ in range(int(input())):
	N = int(input())
	S = input()
	(x, y) = [0] * 2
	last = 0
	for i in range(N):
		this = S[i]
		if this == 'L' and last != 1:
			x -= 1
			last = 1
		elif this == 'R' and last != 1:
			x += 1
			last = 1
		elif this == 'U' and last != 2:
			y += 1
			last = 2
		elif this == 'D' and last != 2:
			y -= 1
			last = 2
	print(x, y)


t = int(input())
while t:
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	for i in range(n):
		if i != 0:
			if s[i] == 'L':
				if s[i - 1] != 'L' and s[i - 1] != 'R':
					x -= 1
			elif s[i] == 'R':
				if s[i - 1] != 'R' and s[i - 1] != 'L':
					x += 1
			elif s[i] == 'U':
				if s[i - 1] != 'U' and s[i - 1] != 'D':
					y += 1
			elif s[i] == 'D':
				if s[i - 1] != 'D' and s[i - 1] != 'U':
					y -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
	print(x, y)
	t -= 1


t = int(input())
for i in range(t):
	(x, y) = (0, 0)
	n = int(input())
	s = input()
	l = ['O']
	for i in s:
		if l[-1] != i:
			l.append(i)
	l.remove('O')
	c = l.copy()
	for i in range(1, len(l)):
		if l[i - 1] == 'U' and l[i] == 'D' or (l[i - 1] == 'D' and l[i] == 'U') or (l[i - 1] == 'R' and l[i] == 'L') or (l[i - 1] == 'L' and l[i] == 'R'):
			c.remove(l[i])
	for a in c:
		if a == 'L':
			x = x - 1
		elif a == 'R':
			x = x + 1
		elif a == 'U':
			y = y + 1
		elif a == 'D':
			y = y - 1
		else:
			pass
	print(x, y)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	l = ['O']
	for i in s:
		if l[-1] != i:
			l.append(i)
	l.remove('O')
	c1 = l.copy()
	for i in range(1, len(l)):
		if (l[i - 1] == 'U' and l[i] == 'D' or (l[i - 1] == 'D' and l[i] == 'U')) or (l[i - 1] == 'R' and l[i] == 'L' or (l[i - 1] == 'L' and l[i] == 'R')):
			c1.remove(l[i])
	x = 0
	y = 0
	for i in c1:
		if i == 'L':
			x = x - 1
		if i == 'R':
			x = x + 1
		if i == 'U':
			y = y + 1
		if i == 'D':
			y = y - 1
	print(x, y)
	t = t - 1


t = int(input())
while t != 0:
	n = int(input())
	s = input()
	(p, q) = (0, 0)
	c = 'N'
	for j in s:
		if j == 'L':
			if c != 'L' and c != 'R':
				p -= 1
		elif j == 'R':
			if c != 'R' and c != 'L':
				p += 1
		elif j == 'U':
			if c != 'U' and c != 'D':
				q += 1
		elif c != 'D' and c != 'U':
			q -= 1
		c = j
	print(p, q)
	t -= 1


for tc in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	lasti = ''
	for i in s:
		if i == 'L':
			if lasti == 'x':
				continue
			else:
				x = x - 1
				lasti = 'x'
		if i == 'R':
			if lasti == 'x':
				continue
			else:
				x = x + 1
				lasti = 'x'
		if i == 'U':
			if lasti == 'y':
				continue
			else:
				y = y + 1
				lasti = 'y'
		if i == 'D':
			if lasti == 'y':
				continue
			else:
				y = y - 1
				lasti = 'y'
	print(x, y)


class Gift:

	def __init__(self, str1):
		self.str1 = str1

	def remDup(self):
		arr = []
		a = []
		for i in self.str1:
			if i not in a:
				arr.append(i)
				if i in ['L', 'R']:
					a = ['L', 'R']
				else:
					a = ['U', 'D']
		return arr

	def find_gift(self):
		self.str2 = Gift(self.str1).remDup()
		x = [0, 0]
		for i in self.str2:
			if i == 'L':
				x[0] -= 1
			elif i == 'R':
				x[0] += 1
			elif i == 'U':
				x[1] += 1
			else:
				x[1] -= 1
		return x
for tc in range(int(input())):
	n = int(input())
	str1 = input()
	obj1 = Gift(str1).find_gift()
	print(*obj1)


t = int(input())
for ni in range(t):
	n = int(input())
	s = input()
	c = 'x'
	(x, y) = (0, 0)
	for i in s:
		if i == 'U' and (c != 'U' and c != 'D'):
			c = 'U'
			y = y + 1
		elif i == 'D' and (c != 'U' and c != 'D'):
			c = 'D'
			y = y - 1
		elif i == 'R' and (c != 'R' and c != 'L'):
			c = 'R'
			x = x + 1
		elif i == 'L' and (c != 'R' and c != 'L'):
			c = 'L'
			x = x - 1
	print(x, y)


try:

	def move(M, l):
		if M == 'L':
			l[0] = l[0] - 1
		elif M == 'R':
			l[0] = l[0] + 1
		elif M == 'U':
			l[1] = l[1] + 1
		elif M == 'D':
			l[1] = l[1] - 1

	def inva(M):
		if M == 'U':
			return 'D'
		elif M == 'D':
			return 'U'
		elif M == 'L':
			return 'R'
		else:
			return 'L'
	for _ in range(int(input())):
		N = int(input())
		S = input()
		l = [0, 0]
		move(S[0], l)
		for i in range(1, len(S)):
			if S[i] != S[i - 1] and S[i] != inva(S[i - 1]):
				move(S[i], l)
		print(*l)
except:
	pass


t = int(input())
dict = {'L': -1, 'R': 1, 'U': 1, 'D': -1}
for i in range(t):
	a = 0
	b = 0
	cx = -1
	n = int(input())
	st = input()
	for j in st:
		if (j == 'L' or j == 'R') and cx != 1:
			cx = 1
			a += dict[j]
		elif (j == 'U' or j == 'D') and cx != 0:
			cx = 0
			b += dict[j]
	print(a, b)


n = int(input())
for _ in range(n):
	k = int(input())
	l = input()
	a = 0
	b = 0
	d = ''
	for x in l:
		if x == 'L' and d != 1:
			a -= 1
			d = 1
		elif x == 'R' and d != 1:
			a += 1
			d = 1
		elif x == 'U' and d != 2:
			b += 1
			d = 2
		elif x == 'D' and d != 2:
			b -= 1
			d = 2
	print(a, b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = 0
	b = 0
	dummy = ''
	for x in s:
		if x == 'L' and dummy != 1:
			a -= 1
			dummy = 1
		elif x == 'R' and dummy != 1:
			a += 1
			dummy = 1
		elif x == 'U' and dummy != 2:
			b += 1
			dummy = 2
		elif x == 'D' and dummy != 2:
			b -= 1
			dummy = 2
	print(a, b)


t = int(input())
for dummy in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	last_dir = 0
	for c in s:
		if c == 'L' and last_dir != 1:
			x -= 1
			last_dir = 1
		elif c == 'R' and last_dir != 1:
			x += 1
			last_dir = 1
		elif c == 'U' and last_dir != 2:
			y += 1
			last_dir = 2
		elif c == 'D' and last_dir != 2:
			y -= 1
			last_dir = 2
	print(x, y)


T = int(input())
for tc in range(T):
	size = int(input())
	string = input()
	switch = 3
	(x, y) = (0, 0)
	for s in range(size):
		if (string[s] == 'L' or string[s] == 'R') and switch != 1:
			if string[s] == 'L':
				x -= 1
			else:
				x += 1
			switch = 1
		if (string[s] == 'U' or string[s] == 'D') and switch != 2:
			if string[s] == 'D':
				y -= 1
			else:
				y += 1
			switch = 2
	print(f'{x} {y}')


for _ in range(int(input())):
	n = int(input())
	s = str(input())
	(x, y) = (0, 0)
	for i in range(n):
		if i != 0:
			if (s[i] == 'L' or s[i] == 'R') and (s[i - 1] == 'L' or s[i - 1] == 'R'):
				continue
			if (s[i] == 'U' or s[i] == 'D') and (s[i - 1] == 'U' or s[i - 1] == 'D'):
				continue
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
	print(x, y)


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	x = 0
	y = 0
	t = ''
	for i in range(len(a)):
		if a[i] == 'L' and t != 'h':
			x = x - 1
			t = 'h'
		elif a[i] == 'R' and t != 'h':
			x = x + 1
			t = 'h'
		elif a[i] == 'U' and t != 'v':
			y = y + 1
			t = 'v'
		elif a[i] == 'D' and t != 'v':
			y = y - 1
			t = 'v'
	print(x, y)


for _ in range(int(input())):
	(x, y) = (0, 0)
	temp = ''
	n = int(input())
	s = input()
	for i in s:
		if i == 'L' and temp != 'horz':
			x -= 1
			temp = 'horz'
		elif i == 'R' and temp != 'horz':
			x += 1
			temp = 'horz'
		elif i == 'U' and temp != 'vert':
			y += 1
			temp = 'vert'
		elif i == 'D' and temp != 'vert':
			y -= 1
			temp = 'vert'
		else:
			continue
	print(x, y)


for i in range(int(input())):
	n = int(input())
	s = input()
	(m, n) = (0, 0)
	l = []
	x = ''
	for i in range(0, len(s)):
		if i == 0:
			if s[i] == 'L' or s[i] == 'R':
				l.extend(['L', 'R'])
			else:
				l.extend(['U', 'D'])
			x += s[i]
		elif s[i] not in l:
			if s[i] == 'L' or s[i] == 'R':
				l.clear()
				l.extend(['L', 'R'])
			else:
				l.clear()
				l.extend(['U', 'D'])
			x += s[i]
	for i in x:
		if i == 'L':
			m -= 1
		elif i == 'R':
			m += 1
		elif i == 'U':
			n += 1
		else:
			n -= 1
	print(m, n)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = ''
	x = 0
	y = 0
	for i in range(n):
		if s[i] == 'L' and a != 'h':
			x -= 1
			a = 'h'
		elif s[i] == 'R' and a != 'h':
			x += 1
			a = 'h'
		elif s[i] == 'U' and a != 'v':
			y += 1
			a = 'v'
		elif s[i] == 'D' and a != 'v':
			y -= 1
			a = 'v'
	print(x, y)


for i in range(int(input())):
	n = int(input())
	s = input()[:n]
	x = 0
	y = 0
	temp = ''
	for j in s:
		if j == 'L' and temp != 'h':
			x = x - 1
			temp = 'h'
		elif j == 'R' and temp != 'h':
			x = x + 1
			temp = 'h'
		elif j == 'U' and temp != 'v':
			y = y + 1
			temp = 'v'
		elif j == 'D' and temp != 'v':
			y = y - 1
			temp = 'v'
	print(x, y)


for _ in range(int(input())):
	x = 0
	y = 0
	prevAxis = 0
	length = int(input())
	directions = input()
	for i in range(length):
		if directions[i] == 'L' or directions[i] == 'R':
			if prevAxis == 1:
				continue
			elif directions[i] == 'L':
				prevAxis = 1
				x -= 1
			elif directions[i] == 'R':
				prevAxis = 1
				x += 1
		if directions[i] == 'U' or directions[i] == 'D':
			if prevAxis == 2:
				continue
			elif directions[i] == 'U':
				prevAxis = 2
				y += 1
			elif directions[i] == 'D':
				prevAxis = 2
				y -= 1
	print('{0} {1}'.format(x, y))


for k in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	val = ''
	for i in s:
		if i == 'L' and val != 'X':
			x -= 1
			val = 'X'
		elif i == 'R' and val != 'X':
			x += 1
			val = 'X'
		elif i == 'U' and val != 'Y':
			y += 1
			val = 'Y'
		elif i == 'D' and val != 'Y':
			y -= 1
			val = 'Y'
	print(x, y)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	a = 0
	b = 0
	p = 0
	for j in s:
		if j == 'L' and p != 'x':
			a -= 1
			p = 'x'
		elif j == 'R' and p != 'x':
			a += 1
			p = 'x'
		elif j == 'U' and p != 'y':
			b += 1
			p = 'y'
		elif j == 'D' and p != 'y':
			b -= 1
			p = 'y'
	print(a, b)


def sol(st):
	if st == 'L':
		way[0] -= 1
	elif st == 'R':
		way[0] += 1
	elif st == 'U':
		way[1] += 1
	else:
		way[1] -= 1
for _ in range(int(input())):
	n = int(input())
	s = input()
	way = [0, 0]
	sol(s[0])
	val = s[0]
	for i in range(1, n):
		if s[i] == val:
			continue
		elif s[i] == 'L' and val == 'R' or (s[i] == 'R' and val == 'L') or (s[i] == 'D' and val == 'U') or (s[i] == 'U' and val == 'D'):
			val = s[i]
			continue
		else:
			sol(s[i])
			val = s[i]
	print(*way, sep=' ')


for i in range(int(input())):
	length_string = int(input())
	string = input()
	(initial_x, initial_y) = (0, 0)
	(xaxis, yaxis) = (['L', 'R'], ['U', 'D'])
	prev = string[0]
	if string[0] == 'L':
		initial_x -= 1
	elif string[0] == 'R':
		initial_x += 1
	elif string[0] == 'U':
		initial_y += 1
	elif string[0] == 'D':
		initial_y -= 1
	index = 0
	for j in range(1, length_string):
		if prev in xaxis and string[j] in xaxis:
			continue
		elif prev in yaxis and string[j] in yaxis:
			continue
		elif string[j] == 'L':
			initial_x -= 1
		elif string[j] == 'R':
			initial_x += 1
		elif string[j] == 'U':
			initial_y += 1
		elif string[j] == 'D':
			initial_y -= 1
		prev = string[j]
	print(initial_x, initial_y)


xaxis = ('L', 'R')
yaxis = ('U', 'D')
for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	last = s[0]
	index = 0
	if s[0] == 'L':
		x -= 1
	elif s[0] == 'R':
		x += 1
	elif s[0] == 'U':
		y += 1
	else:
		y -= 1
	while index < n:
		if last in xaxis:
			if s[index] not in xaxis:
				if s[index] == 'U':
					y += 1
				else:
					y -= 1
				last = s[index]
		elif s[index] not in yaxis:
			if s[index] == 'R':
				x += 1
			else:
				x -= 1
			last = s[index]
		index += 1
	print(x, y)


a = int(input())
for i in range(a):
	n = int(input())
	s = input()
	x = 0
	y = 0
	temp = 0
	for i in s:
		if i == 'L' and temp != 1:
			x = x - 1
			temp = 1
		elif i == 'R' and temp != 1:
			x = x + 1
			temp = 1
		elif i == 'U' and temp != 2:
			y += 1
			temp = 2
		elif i == 'D' and temp != 2:
			y = y - 1
			temp = 2
		else:
			pass
	print(x, y)


for _ in range(int(input())):
	x = int(input())
	y = str(input())
	list = []
	for values in y:
		list.append(values)
	pre_val = ['O', 'O']
	x_axis = 0
	y_axis = 0
	for value in list:
		if pre_val[0] == value or pre_val[1] == value:
			continue
		elif value == 'L':
			x_axis -= 1
			pre_val = ['L', 'R']
		elif value == 'R':
			x_axis += 1
			pre_val = ['L', 'R']
		elif value == 'D':
			y_axis -= 1
			pre_val = ['U', 'D']
		elif value == 'U':
			y_axis += 1
			pre_val = ['U', 'D']
	print(f'{x_axis} {y_axis}')