There is a robot on a coordinate plane. Initially, the robot is located at the point $(0, 0)$. Its path is described as a string $s$ of length $n$ consisting of characters 'L', 'R', 'U', 'D'.

Each of these characters corresponds to some move:   'L' (left): means that the robot moves from the point $(x, y)$ to the point $(x - 1, y)$;  'R' (right): means that the robot moves from the point $(x, y)$ to the point $(x + 1, y)$;  'U' (up): means that the robot moves from the point $(x, y)$ to the point $(x, y + 1)$;  'D' (down): means that the robot moves from the point $(x, y)$ to the point $(x, y - 1)$. 

The company that created this robot asked you to optimize the path of the robot somehow. To do this, you can remove any non-empty substring of the path. But this company doesn't want their customers to notice the change in the robot behavior. It means that if before the optimization the robot ended its path at the point $(x_e, y_e)$, then after optimization (i.e. removing some single substring from $s$) the robot also ends its path at the point $(x_e, y_e)$.

This optimization is a low-budget project so you need to remove the shortest possible non-empty substring to optimize the robot's path such that the endpoint of his path doesn't change. It is possible that you can't optimize the path. Also, it is possible that after the optimization the target path is an empty string (i.e. deleted substring is the whole string $s$).

Recall that the substring of $s$ is such string that can be obtained from $s$ by removing some amount of characters (possibly, zero) from the prefix and some amount of characters (possibly, zero) from the suffix. For example, the substrings of "LURLLR" are "LU", "LR", "LURLLR", "URL", but not "RR" and "UL".

You have to answer $t$ independent test cases.


-----Input-----

The first line of the input contains one integer $t$ ($1 \le t \le 1000$) — the number of test cases.

The next $2t$ lines describe test cases. Each test case is given on two lines. The first line of the test case contains one integer $n$ ($1 \le n \le 2 \cdot 10^5$) — the length of the robot's path. The second line of the test case contains one string $s$ consisting of $n$ characters 'L', 'R', 'U', 'D' — the robot's path.

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$ ($\sum n \le 2 \cdot 10^5$).


-----Output-----

For each test case, print the answer on it. If you cannot remove such non-empty substring that the endpoint of the robot's path doesn't change, print -1. Otherwise, print two integers $l$ and $r$ such that $1 \le l \le r \le n$ — endpoints of the substring you remove. The value $r-l+1$ should be minimum possible. If there are several answers, print any of them.


-----Example-----
Input
4
4
LRUD
4
LURD
5
RRUDU
5
LLDDR

Output
1 2
1 4
3 4
-1

Difficulty: MEDIUM
Tags: Data structures

Implementation
Skill types: Data structures

Starter code:

Solutions:
t = int(input())
for _ in range(t):
	r = {}
	x = 0
	y = 0
	n = int(input())
	s = input()
	r[x, y] = 0
	ans = []
	for i in range(len(s)):
		if s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		if (x, y) in r.keys():
			ans.append([i - r[x, y], r[x, y] + 1, i + 1])
			r[x, y] = i + 1
		else:
			r[x, y] = i + 1
	if len(ans) == 0:
		print('-1')
	else:
		print(*min(ans)[1:])


t = int(input())
move = {'L': -1, 'R': 1, 'U': -1, 'D': 1}
for i in range(t):
	n = int(input())
	s = list(input())
	ans = [-1, n]
	sw = False
	tem = (0, 0)
	ha = {}
	ha[tem] = 0
	for i in range(n):
		if s[i] == 'L' or s[i] == 'R':
			tem = (tem[0] + move[s[i]], tem[1])
		else:
			tem = (tem[0], tem[1] + move[s[i]])
		if tem in ha.keys():
			if ans[1] - ans[0] > i - ha[tem]:
				ans = [ha[tem] + 1, i + 1]
				sw = True
		ha[tem] = i + 1
	if sw:
		print(ans[0], ans[1])
	else:
		print(-1)


import sys
import os
from io import IOBase, BytesIO
import math
mod = 10 ** 9 + 7
pie = 3.1415926536

def modinv(n, p):
	return pow(n, p - 2, p)

def ncr(n, r, p):
	t = fact[n] * (ifact[r] * ifact[n - r] % p) % p
	return t

def ain():
	return list(map(int, sin().split()))

def sin():
	return input().strip()

def GCD(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def read2DIntArray(row, col):
	arr = []
	for i in range(0, row):
		temp = list(map(int, sin().split()))
		arr.append(temp)
	return arr

def read2DCharArray(row, col):
	arr = []
	for i in range(0, row):
		temp = str(sin())
		arr.append(temp)
	return arr

def smallestNumber(n):
	lst = list(str(n))
	lst.sort()
	tmp = ''
	for (i, n) in enumerate(lst):
		if n != '0':
			tmp = lst.pop(i)
			break
	return str(tmp) + ''.join(lst)

def SieveOfEratosthenes(n):
	prime = [True for i in range(n + 1)]
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * 2, n + 1, p):
				prime[i] = False
		p += 1
	prime[0] = False
	prime[1] = False
	lst = []
	for p in range(n + 1):
		if prime[p]:
			lst.append(p)
	return lst

def nCr(n, r):
	a = 1
	b = 1
	c = 1
	for i in range(1, n + 1):
		c *= i
	for i in range(1, r + 1):
		b *= i
	for i in range(1, n - r + 1):
		a *= i
	return c // (a * b)

def sieveOfEratosthenes1(N, s):
	prime = [False] * (N + 1)
	for i in range(2, N + 1, 2):
		s[i] = 2
	for i in range(3, N + 1, 2):
		if prime[i] == False:
			s[i] = i
			for j in range(i, int(N / i) + 1, 2):
				if prime[i * j] == False:
					prime[i * j] = True
					s[i * j] = i

def generatePrimeFactors(N):
	s = [0] * (N + 1)
	sieveOfEratosthenes1(N, s)
	curr = s[N]
	cnt = 1
	factors = []
	power = []
	while N > 1:
		N //= s[N]
		if curr == s[N]:
			cnt += 1
			continue
		factors.append(curr)
		power.append(cnt)
		curr = s[N]
		cnt = 1
	return (factors, power)

def main():
	for _ in range(int(sin())):
		n = int(sin())
		s = sin()
		dic = {}
		dic[0, 0] = [0]
		(x, y) = (0, 0)
		l = -1
		r = -1
		length = 2 * 10 ** 5 + 1
		for i in range(n):
			d = s[i]
			if d == 'R':
				x += 1
			elif d == 'L':
				x -= 1
			elif d == 'U':
				y += 1
			else:
				y -= 1
			if (x, y) in dic.keys():
				dic[x, y].append(i + 1)
			else:
				dic[x, y] = [i + 1]
		for ele in dic:
			l1 = dic[ele]
			if len(l1) > 1:
				for i in range(len(l1) - 1):
					if l1[i + 1] - l1[i] < length:
						length = l1[i + 1] - l1[i]
						l = l1[i] + 1
						r = l1[i + 1]
		if l == -1 and r == -1:
			print('-1')
		else:
			print(l, r)
py2 = round(0.5)
if py2:
	from future_builtins import ascii, filter, hex, map, oct, zip
	range = xrange
BUFSIZE = 8192

class FastIO(BytesIO):
	newlines = 0

	def __init__(self, file):
		self._file = file
		self._fd = file.fileno()
		self.writable = 'x' in file.mode or 'w' in file.mode
		self.write = super(FastIO, self).write if self.writable else None

	def _fill(self):
		s = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
		self.seek((self.tell(), self.seek(0, 2), super(FastIO, self).write(s))[0])
		return s

	def read(self):
		while self._fill():
			pass
		return super(FastIO, self).read()

	def readline(self):
		while self.newlines == 0:
			s = self._fill()
			self.newlines = s.count(b'\n') + (not s)
		self.newlines -= 1
		return super(FastIO, self).readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.getvalue())
			(self.truncate(0), self.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		if py2:
			self.write = self.buffer.write
			self.read = self.buffer.read
			self.readline = self.buffer.readline
		else:
			self.write = lambda s: self.buffer.write(s.encode('ascii'))
			self.read = lambda : self.buffer.read().decode('ascii')
			self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))

def input():
	return sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	arr = input()
	(x, y) = (0, 0)
	d = {}
	d[x, y] = -1
	flen = int(10000000000.0)
	st = -1
	end = -1
	for i in range(n):
		if arr[i] == 'L':
			x -= 1
		elif arr[i] == 'R':
			x += 1
		elif arr[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			l = i - d[tuple([x, y])] + 1
			if l < flen:
				flen = l
				st = d[x, y]
				end = i
		d[x, y] = i
	if flen == int(10000000000.0):
		print(-1)
	else:
		print(st + 2, end + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	x = y = 0
	visited = {(x, y): 0}
	i = 1
	min_len = n + 1
	l = -1
	r = n
	for j in range(n):
		if s[j] == 'L':
			x -= 1
		elif s[j] == 'R':
			x += 1
		elif s[j] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in visited:
			if i - visited[x, y] < min_len:
				l = visited[x, y]
				r = i
				min_len = i - visited[x, y]
		visited[x, y] = i
		i += 1
	if min_len > n:
		print(-1)
	else:
		print(l + 1, r)


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = list(input())
	a = [-1 if s[i] == 'L' else 1 if s[i] == 'R' else 0 for i in range(n)]
	b = [-1 if s[i] == 'D' else 1 if s[i] == 'U' else 0 for i in range(n)]
	suma = [a[0] for _ in range(n)]
	sumb = [b[0] for _ in range(n)]
	d = dict()
	d[0, 0] = -1
	for i in range(1, n):
		suma[i] = suma[i - 1] + a[i]
		sumb[i] = sumb[i - 1] + b[i]
	res = n + 1
	_res = -1
	for i in range(n):
		if (suma[i], sumb[i]) in d.keys():
			if res > i - d[suma[i], sumb[i]]:
				res = i - d[suma[i], sumb[i]]
				_res = (d[suma[i], sumb[i]], i)
		d[suma[i], sumb[i]] = i
	if _res == -1:
		print(_res)
	else:
		print(_res[0] + 2, _res[1] + 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	dic = {(0, 0): -1}
	x = 0
	y = 0
	ln = 1000000000000
	p = 0
	q = 0
	b = False
	for j in range(n):
		if s[j] == 'L':
			x -= 1
		elif s[j] == 'R':
			x += 1
		elif s[j] == 'U':
			y += 1
		elif s[j] == 'D':
			y -= 1
		tp = (x, y)
		if tp in dic:
			dis = j - dic[tp]
			if dis < ln:
				b = True
				ln = dis
				p = dic[tp] + 1
				q = j
		dic[tp] = j
	if not b:
		print('-1')
	else:
		print(p + 1, q + 1)


def remover(n, journey):
	result_left = 1
	result_right = 10 ** 7
	history = dict()
	history[0, 0] = 0
	x = 0
	y = 0
	for (i, step) in enumerate(journey):
		if step == 'U':
			y += 1
		elif step == 'D':
			y -= 1
		elif step == 'R':
			x += 1
		elif step == 'L':
			x -= 1
		if (x, y) in history:
			if result_right - result_left + 1 > i + 1 - history[x, y]:
				result_left = history[x, y] + 1
				result_right = i + 1
		history[x, y] = i + 1
	return (result_left, result_right)

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		journey = list(input())
		(border_left, border_right) = remover(n, journey)
		if border_right == 10 ** 7:
			print(-1)
			continue
		else:
			print(border_left, border_right)
	return 0
main()


import collections

def solve(n, string):
	(currX, currY) = (0, 0)
	seen = collections.defaultdict(int)
	seen[currX, currY] = 0
	(ansLeft, ansRight) = (-1, n)
	for (i, ch) in enumerate(string):
		if ch == 'L':
			currX -= 1
		elif ch == 'R':
			currX += 1
		elif ch == 'U':
			currY += 1
		else:
			currY -= 1
		key = (currX, currY)
		if key in seen:
			if i - seen[key] + 1 < ansRight - ansLeft + 1:
				ansLeft = seen[key]
				ansRight = i
		seen[key] = i + 1
	if ansLeft == -1:
		return '-1'
	else:
		return '{} {}'.format(ansLeft + 1, ansRight + 1)
t = int(input().strip())
for i in range(t):
	n = int(input().strip())
	string = input().strip()
	print(solve(n, string))


import collections

def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		pos = collections.defaultdict(lambda : set())
		xpos = 0
		ypos = 0
		pos['0 0'].add(0)
		for i in range(1, n + 1):
			x = s[i - 1]
			if x == 'L':
				xpos -= 1
			elif x == 'R':
				xpos += 1
			elif x == 'U':
				ypos += 1
			else:
				ypos -= 1
			pos[str(xpos) + ' ' + str(ypos)].add(i)
		ans1 = 0
		ans2 = 0
		mini = 10 ** 10
		for x in pos.values():
			if len(x) > 1:
				l = list(x)
				l.sort()
				for i in range(len(x) - 1):
					if l[i + 1] - l[i] < mini:
						ans1 = l[i] + 1
						ans2 = l[i + 1]
						mini = l[i + 1] - l[i]
		if mini == 10 ** 10:
			if xpos == 0 and ypos == 0:
				print(1, n)
			else:
				print(-1)
		else:
			print(ans1, ans2)
main()


import sys
import bisect
import math as mt
t = int(input())
mod = 10 ** 9 + 7
for _ in range(t):
	n = int(input())
	s = input()
	d = {}
	px = [0] * (n + 1)
	py = [0] * (n + 1)
	for i in range(n):
		if s[i] == 'U' or s[i] == 'D':
			if s[i] == 'U':
				py[i + 1] = py[i] + 1
			else:
				py[i + 1] = py[i] - 1
			px[i + 1] = px[i]
		else:
			if s[i] == 'L':
				px[i + 1] = px[i] - 1
			else:
				px[i + 1] = px[i] + 1
			py[i + 1] = py[i]
	d[0, 0] = 0
	(l, r) = (0, 10 ** 6)
	for i in range(n):
		if d.get((px[i + 1], py[i + 1]), -1) != -1:
			if r - l + 1 > i + 1 - d[px[i + 1], py[i + 1]]:
				(l, r) = (d[px[i + 1], py[i + 1]] + 1, i + 1)
		d[px[i + 1], py[i + 1]] = i + 1
	if r - l == 10 ** 6:
		print(-1)
	else:
		print(l, r)


t = int(input())
for i in range(t):
	n = int(input())
	inp = input()
	dic = {(0, 0): [0]}
	dir_dic = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
	cord = [0, 0]
	flag = 0
	for (i, elem) in enumerate(inp):
		cord[0] += dir_dic[elem][0]
		cord[1] += dir_dic[elem][1]
		tup_cord = tuple(cord)
		if tup_cord in dic:
			if flag:
				if i - dic[tup_cord][-1] + 1 < ans[1] - ans[0] + 1:
					ans = (dic[tup_cord][-1] + 1, i + 1)
			else:
				flag = 1
				ans = (dic[tup_cord][-1] + 1, i + 1)
			dic[tup_cord].append(i + 1)
		else:
			dic[tup_cord] = [i + 1]
	if flag:
		print(*ans)
	else:
		print(-1)


def solve(path_length, path):

	def step(cur_x, cur_y, direction):
		if direction == 'L':
			return (cur_x - 1, cur_y)
		elif direction == 'U':
			return (cur_x, cur_y + 1)
		elif direction == 'R':
			return (cur_x + 1, cur_y)
		else:
			return (cur_x, cur_y - 1)
	passed_points = {(0, 0): 0}
	cycles = []
	temp_x = 0
	temp_y = 0
	cur_min_len = path_length
	cur_start = -1
	for i in range(path_length):
		(temp_x, temp_y) = step(temp_x, temp_y, path[i])
		if passed_points.get((temp_x, temp_y)) is not None:
			t_start = passed_points[temp_x, temp_y]
			t_length = i - t_start
			if t_length < cur_min_len:
				cur_min_len = t_length
				cur_start = t_start
		passed_points[temp_x, temp_y] = i + 1
	return cur_start if cur_start == -1 else f'{cur_start + 1} {cur_start + cur_min_len + 1}'
t = int(input())
for m_i in range(0, t):
	temp_length = int(input())
	temp_path = input()
	result = solve(temp_length, temp_path)
	print(result)


ITR = int(input())
import math
for itr in range(ITR):
	N = int(input())
	path = input()
	explored = {}
	curr = [0, 0]
	explored[0, 0] = 0
	minPath = None
	minPathLength = 0
	for i in range(len(path)):
		direct = path[i]
		if direct == 'L':
			curr[0] -= 1
		elif direct == 'R':
			curr[0] += 1
		elif direct == 'U':
			curr[1] += 1
		else:
			curr[1] -= 1
		tup = (curr[0], curr[1])
		if tup in explored:
			pathLength = i + 1 - explored[tup]
			if minPath is None or minPathLength > pathLength:
				minPath = (explored[tup], i)
				minPathLength = pathLength
		explored[tup] = i + 1
	if minPath is not None:
		print(str(minPath[0] + 1) + ' ' + str(minPath[1] + 1))
	else:
		print(-1)


test = int(input())
for ___ in range(test):
	n = int(input())
	s = input()
	x = 0
	y = 0
	coordinates = {(x, y): -1}
	min = 2 ** 31
	start = -1
	stop = -1
	j = 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, y) in coordinates:
			ind = coordinates[x, y] + 1
			if j - ind < min:
				start = ind
				stop = j
				min = stop - start
			coordinates[x, y] = j
		else:
			coordinates[x, y] = j
		j += 1
	if start != -1:
		print(start + 1, stop + 1)
	else:
		print(-1)


T = int(input())
t = 0
while t < T:
	N = int(input())
	s = input()
	X = 0
	Y = 0
	risultato = 20000001
	trovato = False
	p = {(X, Y): 0}
	n = 0
	a = N
	b = N
	while n < N:
		c = s[n]
		if c == 'U':
			Y += 1
		if c == 'D':
			Y -= 1
		if c == 'R':
			X += 1
		if c == 'L':
			X -= 1
		if (X, Y) in p:
			if n + 1 - p[X, Y] < risultato:
				a = p[X, Y] + 1
				b = n + 1
				risultato = n + 1 - p[X, Y]
				trovato = True
		p[X, Y] = n + 1
		n = n + 1
	if trovato:
		print(a, b)
	else:
		print(-1)
	t = t + 1


import sys
input = sys.stdin.readline
t = int(input())
for j in range(t):
	n = int(input())
	arr = list(input())
	x = y = 0
	d = {}
	d[x, y] = 0
	start = -1
	end = n
	for i in range(n):
		if arr[i] == 'R':
			y += 1
		elif arr[i] == 'L':
			y -= 1
		elif arr[i] == 'U':
			x += 1
		elif arr[i] == 'D':
			x -= 1
		if (x, y) in d:
			if i - d[x, y] < end - start:
				end = i
				start = d[x, y]
		d[x, y] = i + 1
	if start == -1:
		print(-1)
	else:
		print(start + 1, end + 1)


test_cases = int(input())
for test_case in range(test_cases):
	moves_len = int(input())
	moves = list(input())
	visited_points = dict()
	x = 0
	y = 0
	visited_points[x, y] = -1
	minimum_substring = None
	minimum_substring_len = moves_len + 10
	for index in range(moves_len):
		if moves[index] == 'L':
			x -= 1
		elif moves[index] == 'R':
			x += 1
		elif moves[index] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in visited_points:
			starting_point = visited_points[x, y]
			if index - starting_point < minimum_substring_len:
				minimum_substring = (starting_point, index)
				minimum_substring_len = index - starting_point
		visited_points[x, y] = index
	if not minimum_substring:
		print('-1')
	else:
		print(minimum_substring[0] + 2, minimum_substring[1] + 1)


t = int(input())
D = {'L': (-1, 0), 'R': (1, 0), 'D': (0, -1), 'U': (0, 1)}
for _ in range(t):
	n = int(input())
	s = 0
	pos = (0, 0)
	(best, best_i) = (-1, -1)
	B = {}
	B[pos] = 0
	for p in input():
		s += 1
		pos = (pos[0] + D[p][0], pos[1] + D[p][1])
		if pos in B:
			if best == -1 or best > s - B[pos]:
				best = s - B[pos]
				best_i = B[pos] + 1
		B[pos] = s
	if best == -1:
		print(-1)
	else:
		print(str(best_i) + ' ' + str(best_i + best - 1))


for _ in range(int(input())):
	input()
	s = input()
	m = {(0, 0): -1}
	x = 0
	y = 0
	best = 1000000
	l = -2
	for (i, e) in enumerate(s):
		if e == 'L':
			x -= 1
		elif e == 'R':
			x += 1
		elif e == 'U':
			y += 1
		elif e == 'D':
			y -= 1
		if (x, y) in m:
			dist = i - m[x, y]
			if dist < best:
				best = dist
				l = m[x, y]
		m[x, y] = i
	if l == -2:
		print(l + 1)
		continue
	print(l + 2, l + best + 1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	j = 1
	(x, y) = (0, 0)
	c = -2
	l = []
	d = dict()
	d[x, y] = 0
	m = n
	(xx, yy) = (0, 0)
	for i in range(n):
		if s[i] == 'R':
			x = x + 1
		elif s[i] == 'L':
			x = x - 1
		elif s[i] == 'D':
			y = y - 1
		else:
			y = y + 1
		if (x, y) in d:
			c = d[x, y]
			d[x, y] = i + 1
			if m > abs(i + 1 - (c + 1)):
				xx = c + 1
				yy = i + 1
				m = abs(i + 1 - (c + 1))
		else:
			d[x, y] = i + 1
	if c == -2:
		print(-1)
	else:
		print(xx, yy)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = (0, 0)
	l1 = {}
	l1[d] = 0
	l = -1
	r = n
	for i in range(n):
		if s[i] == 'R':
			d = (d[0] + 1, d[1])
		if s[i] == 'L':
			d = (d[0] - 1, d[1])
		if s[i] == 'U':
			d = (d[0], d[1] + 1)
		if s[i] == 'D':
			d = (d[0], d[1] - 1)
		if d in l1:
			if i - l1[d] + 1 < r - l + 1:
				l = l1[d]
				r = i
		l1[d] = i + 1
	if l == -1:
		print('-1')
	else:
		print(l + 1, r + 1)


from sys import stdin
input = stdin.readline
t = int(input())
arr = [input() for _ in range(2 * t)]
res = []
for e in range(t):
	n = int(arr[2 * e])
	s = arr[2 * e + 1]
	d = {(0, 0): [0]}
	(cx, cy) = (0, 0)
	for i in range(n):
		if s[i] == 'L':
			cx -= 1
		if s[i] == 'R':
			cx += 1
		if s[i] == 'U':
			cy += 1
		if s[i] == 'D':
			cy -= 1
		if (cx, cy) in d:
			d[cx, cy].append(i + 1)
		else:
			d[cx, cy] = [i + 1]
	(mini, a, b) = (int(2000000000.0), -1, -1)
	for i in d:
		if len(d[i]) < 2:
			continue
		for j in range(1, len(d[i])):
			if mini > d[i][j] - d[i][j - 1]:
				mini = d[i][j] - d[i][j - 1]
				(b, a) = (d[i][j], d[i][j - 1])
	if mini == int(2000000000.0):
		res.append(str(-1))
	else:
		res.append(str(a + 1) + ' ' + str(b))
print('\n'.join(res))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	path = {(0, 0): 0}
	x = 0
	y = 0
	numSteps = 0
	cycleSize = 1000000
	l = None
	r = None
	for m in s:
		numSteps += 1
		if m == 'R':
			x += 1
		elif m == 'L':
			x -= 1
		elif m == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) not in path:
			path[x, y] = numSteps
		else:
			if numSteps - path[x, y] < cycleSize:
				l = path[x, y]
				r = numSteps
				cycleSize = r - l
			path[x, y] = numSteps
	if l == None:
		print(-1)
	else:
		print(l + 1, r)


def shortest_deletion(path):
	path = list(path)
	positions = [(0, 0)]
	positions_steps = {}
	positions_steps[0, 0] = 0
	min_cycle_len = 10 ** 6
	min_cycle_left = -1
	min_cycle_right = -1
	current_step = 1
	for move in path:
		if move == 'U':
			new_position = (positions[-1][0], positions[-1][1] + 1)
		elif move == 'L':
			new_position = (positions[-1][0] - 1, positions[-1][1])
		elif move == 'D':
			new_position = (positions[-1][0], positions[-1][1] - 1)
		else:
			new_position = (positions[-1][0] + 1, positions[-1][1])
		positions.append(new_position)
		if new_position in positions_steps:
			cycle_right = current_step
			cycle_left = positions_steps[new_position]
			cycle_len = cycle_right - cycle_left
			if cycle_len < min_cycle_len:
				min_cycle_left = cycle_left
				min_cycle_right = cycle_right
				min_cycle_len = cycle_len
		positions_steps[new_position] = current_step
		current_step += 1
	if min_cycle_left != -1:
		return (min_cycle_left + 1, min_cycle_right)
	else:
		return (-1, -1)
t = int(input())
for i in range(t):
	n = int(input())
	path = input()
	(left, right) = shortest_deletion(path)
	if left == -1:
		print(-1)
	else:
		print(left, right)


import math
t = int(input())
for i in range(t):
	d = dict()
	(x, y) = (0, 0)
	move = 0
	d[x, y] = move
	n = int(input())
	bestmove = math.inf
	(bl, br) = (-1, -1)
	for c in input():
		move += 1
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		if (x, y) in d and move - d[x, y] < bestmove:
			bestmove = move - d[x, y]
			bl = d[x, y]
			br = move
		d[x, y] = move
	if bl != -1:
		print(bl + 1, br)
	else:
		print(-1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	road = defaultdict(list)
	now = 0 + 0j
	road[now] = 0
	ans = [-10 ** 8, -1]
	for (i, x) in enumerate(s):
		if x == 'L':
			now += 1
		if x == 'R':
			now -= 1
		if x == 'U':
			now += 1j
		if x == 'D':
			now -= 1j
		if now in road:
			if ans[1] - ans[0] + 1 > i + 1 - road[now]:
				ans = [road[now] + 1, i + 1]
		road[now] = i + 1
	if ans[0] == -10 ** 8:
		print(-1)
	else:
		print(*ans)


dx = {'L': -1, 'R': 1, 'U': 0, 'D': 0}
dy = {'L': 0, 'R': 0, 'U': 1, 'D': -1}
for _ in range(int(input())):
	n = int(input())
	s = input()
	m = {(0, 0): 0}
	c = (0, 0)
	l = -1
	r = float('inf')
	for i in range(n):
		c = (c[0] + dx[s[i]], c[1] + dy[s[i]])
		if c in m:
			if i + 1 - m[c] < r - l:
				l = m[c]
				r = i + 1
		m[c] = i + 1
	if l < 0:
		print(l)
	else:
		print(l + 1, r)


def solve():
	n = int(input())
	path = input()
	(x, y) = (0, 0)
	(start, end) = (0, 0)
	mem = {'0 0': 0}
	sol = False
	(final_count, final_start, final_end) = (0, 0, 0)
	for (i, p) in enumerate(path):
		if p == 'U':
			y += 1
		elif p == 'D':
			y -= 1
		elif p == 'L':
			x -= 1
		elif p == 'R':
			x += 1
		key = f'{x} {y}'
		start = mem.get(key, -1)
		if start >= 0:
			end = i + 1
			start += 1
			count = end - start + 1
			if not sol or final_count > count:
				final_count = count
				(final_start, final_end) = (start, end)
			sol = True
		mem[key] = i + 1
	if not sol:
		print(-1)
	else:
		print(final_start, final_end)

def main():
	t = int(input())
	for _ in range(t):
		solve()
main()


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
Ri = lambda : [int(x) for x in sys.stdin.readline().split()]
ri = lambda : sys.stdin.readline().strip()
for _ in range(int(ri())):
	n = int(ri())
	s = ri()
	dic = {(0, 0): -1}
	(x, y) = (0, 0)
	l = 10 ** 18
	(sta, end) = (-1, -1)
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if (x, y) not in dic:
			dic[x, y] = i
		else:
			if i - dic[x, y] - 1 + 1 < l:
				l = i - dic[x, y] - 1 + 1
				sta = dic[x, y] + 1 + 1
				end = i + 1
			dic[x, y] = i
	if l == 10 ** 18:
		print(-1)
	else:
		print(sta, end)


import math
t = int(input())
answers = []
for ti in range(t):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	path = {(0, 0): 0}
	ans = []
	for i in range(len(s)):
		c = s[i]
		if c == 'R':
			x += 1
		elif c == 'L':
			x -= 1
		elif c == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in path:
			ans.append([path[x, y] + 1, i + 1])
		path[x, y] = i + 1
	if len(ans) > 0:
		_min = ans[0]
		for a in ans:
			if a[1] - a[0] < _min[1] - _min[0]:
				_min = a
		answers.append(str(_min[0]) + ' ' + str(_min[1]))
	else:
		answers.append('-1')
for a in answers:
	print(a)


import sys, os, io

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

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

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

def ws(s):
	sys.stdout.write(s + '\n')

def wi(n):
	sys.stdout.write(str(n) + '\n')

def wia(a):
	sys.stdout.write(' '.join([str(x) for x in a]) + '\n')
import math, datetime, functools, itertools, operator, bisect, fractions, statistics
from collections import deque, defaultdict, OrderedDict, Counter
from fractions import Fraction
from decimal import Decimal
from sys import stdout

def main():
	starttime = datetime.datetime.now()
	if os.path.exists('input.txt'):
		sys.stdin = open('input.txt', 'r')
		sys.stdout = open('output.txt', 'w')
	for _ in range(ri()):
		n = ri()
		a = rs()
		(x, y) = (0, 0)
		d = {}
		d[x, y] = [0]
		c = 0
		for i in a:
			c += 1
			if i == 'L':
				x -= 1
			if i == 'R':
				x += 1
			if i == 'U':
				y += 1
			if i == 'D':
				y -= 1
			k = (x, y)
			if k in d:
				d[k].append(c)
			else:
				d[k] = [c]
		ans = 99999999999999999999
		aslians = (-1, -1)
		c = 1
		for i in d:
			if len(d[i]) > 1:
				z = d[i]
				for i in range(1, len(z)):
					if z[i] - z[i - 1] < ans:
						ans = z[i] - z[i - 1]
						aslians = (z[i - 1] + 1, z[i])
				c = 0
		if c == 0:
			print(*aslians)
		else:
			print(-1)
	endtime = datetime.datetime.now()
	time = (endtime - starttime).total_seconds() * 1000
	if os.path.exists('input.txt'):
		print('Time:', time, 'ms')

class FastReader(io.IOBase):
	newlines = 0

	def __init__(self, fd, chunk_size=1024 * 8):
		self._fd = fd
		self._chunk_size = chunk_size
		self.buffer = io.BytesIO()

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self, size=-1):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, self._chunk_size if size == -1 else size))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

class FastWriter(io.IOBase):

	def __init__(self, fd):
		self._fd = fd
		self.buffer = io.BytesIO()
		self.write = self.buffer.write

	def flush(self):
		os.write(self._fd, self.buffer.getvalue())
		(self.buffer.truncate(0), self.buffer.seek(0))

class FastStdin(io.IOBase):

	def __init__(self, fd=0):
		self.buffer = FastReader(fd)
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

class FastStdout(io.IOBase):

	def __init__(self, fd=1):
		self.buffer = FastWriter(fd)
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.flush = self.buffer.flush
sys.stdin = FastStdin()
sys.stdout = FastStdout()
main()


import sys
reader = (s.rstrip() for s in sys.stdin)
input = reader.__next__
dic = {'L': [-1, 0], 'R': 1, 'U': 2, 'D': 3}

def cashback():
	for _ in range(t):
		prevpath = {(0, 0): [0]}
		n = int(input())
		string = input()
		currloc = [0, 0]
		mindis = float('Inf')
		startloc = None
		for i in range(n):
			(x, y) = currloc
			if string[i] == 'L':
				currloc = [x - 1, y]
			elif string[i] == 'R':
				currloc = [x + 1, y]
			elif string[i] == 'U':
				currloc = [x, y + 1]
			elif string[i] == 'D':
				currloc = [x, y - 1]
			(x, y) = currloc
			exist = prevpath.get((x, y), None)
			if exist:
				if i + 1 - exist[-1] < mindis:
					mindis = i + 1 - exist[-1]
					startloc = exist[-1] + 1
				prevpath[x, y] += [i + 1]
			else:
				prevpath[x, y] = [i + 1]
		if startloc:
			yield (str(startloc) + ' ' + str(startloc + mindis - 1))
		else:
			yield (-1)
t = int(input())
ans = cashback()
print(*ans, sep='\n')


from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time

def I():
	return int(input())

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

def S():
	return input()

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

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def StoI():
	return [ord(i) - 97 for i in input()]

def ItoS(nn):
	return chr(nn + 97)

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

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
YN = {False: 'No', True: 'Yes'}
MOD = 10 ** 9 + 7
inf = float('inf')
IINF = 10 ** 10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']
show_flg = False
import random

def solve(T):
	N = I()
	s = S()
	test3 = {'[0, 0]': [0]}
	pos = [0, 0]
	can = []
	for i in range(N):
		if s[i] == 'U':
			pos[1] += 1
		elif s[i] == 'D':
			pos[1] -= 1
		elif s[i] == 'R':
			pos[0] += 1
		elif s[i] == 'L':
			pos[0] -= 1
		str_pos = str(pos)
		if str_pos not in test3:
			test3[str_pos] = [i + 1]
		else:
			can.append((i - test3[str_pos][-1], test3[str_pos][-1]))
			test3[str_pos] = []
			test3[str_pos].append(i + 1)
	can = sorted(can)
	if len(can) > 0:
		print(can[0][1] + 1, can[0][1] + 1 + can[0][0])
	else:
		print(-1)

def main():
	T = I()
	for i in range(T):
		solve(T)
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	d = dict()
	(x, y) = (0, 0)
	d[x, y] = 0
	c = n + 1
	ans = (-1,)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			b = i - d[x, y]
			if b < c:
				c = b
				ans = (d[x, y] + 1, i + 1)
		d[x, y] = i + 1
	print(*ans)


I = input
d = dict(zip('LRDU', ((-1, 0), (1, 0), (0, -1), (0, 1))))
for _ in [0] * int(I()):
	I()
	a = {(0, 0): 0}
	i = s = t = 0
	r = (-1,)
	m = 300000.0
	for c in I():
		i += 1
		(x, y) = d[c]
		s += x
		t += y
		j = a.get((s, t), -m)
		if i - j < m:
			m = i - j
			r = (j + 1, i)
		a[s, t] = i
	print(*r)


from collections import Counter
for trt in range(int(input())):
	n = int(input())
	l = list(input())
	x = Counter(l)
	flag = 0
	for t in x:
		if x[t] == n:
			print(-1)
			flag = 1
			break
	if flag == 0:
		lr = 0
		ud = 0
		t = 0
		d = {}
		ans = []
		d[0, 0] = 0
		for t in range(n):
			if l[t] == 'U':
				ud += 1
			elif l[t] == 'D':
				ud -= 1
			elif l[t] == 'L':
				lr -= 1
			else:
				lr += 1
			if (ud, lr) not in d:
				d[ud, lr] = t + 1
			else:
				ans.append([t + 1, d[ud, lr]])
				d[ud, lr] = t + 1
		if len(ans) == 0:
			print(-1)
		else:
			k = []
			for t in ans:
				k.append(t[0] - t[1])
			vb = min(k)
			j = k.index(vb)
			print(ans[j][1] + 1, ans[j][0])


t = int(input())
for i in range(t):
	l = r = 0
	diff = 999999999
	dc = {}
	st = {(0, 0)}
	dc[0, 0] = -1
	n = int(input())
	s = input()
	lr = ud = 0
	for (i, c) in enumerate(s):
		if c == 'L':
			lr = lr - 1
		elif c == 'R':
			lr = lr + 1
		elif c == 'U':
			ud = ud + 1
		elif c == 'D':
			ud = ud - 1
		if (lr, ud) in st:
			if i - dc[lr, ud] < diff:
				diff = i - dc[lr, ud]
				l = dc[lr, ud]
				r = i
			dc[lr, ud] = i
		else:
			st.add((lr, ud))
			dc[lr, ud] = i
	if l == 0 and r == 0:
		print(-1)
	else:
		print(l + 2, r + 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	b = dict()
	b[0, 0] = 0
	ans = [-1, -1]
	alen = 9999999999
	(curr, curu) = (0, 0)
	for i in range(len(s)):
		j = s[i]
		if j == 'R':
			curr += 1
		elif j == 'L':
			curr -= 1
		elif j == 'U':
			curu += 1
		elif j == 'D':
			curu -= 1
		num = b.get((curr, curu), -1)
		if num != -1 and i - num + 2 < alen:
			ans = [num + 1, i + 1]
			alen = i - num + 2
		b[curr, curu] = i + 1
	if ans != [-1, -1]:
		print(*ans)
	else:
		print(-1)


import math
T = int(input())
n = [0] * T
a = [0] * T
for t in range(T):
	n[t] = int(input())
	a[t] = list(input())
r = {'R': 1, 'L': -1, 'U': 0, 'D': 0}
u = {'R': 0, 'L': 0, 'U': 1, 'D': -1}
for t in range(T):
	R = {0 + 0j: [0]}
	rtot = 0 + 0j
	for i in range(n[t]):
		rtot += complex(r[a[t][i]], u[a[t][i]])
		if rtot in R:
			R[rtot].append(i + 1)
		else:
			R[rtot] = [i + 1]
	sgap = n[t] + 1
	smol = (0, n[t] + 1)
	R = list(R.values())
	for i in range(len(R)):
		if len(R[i]) > 1:
			for g in range(1, len(R[i])):
				if R[i][g] - R[i][g - 1] < sgap:
					smol = (R[i][g - 1] + 1, R[i][g])
					sgap = R[i][g] - R[i][g - 1]
	if sgap < n[t] + 1:
		print(smol[0], smol[1])
	else:
		print(-1)


q = int(input())
for _ in range(q):
	n = int(input())
	s = str(input())
	dict1 = {}
	dict1[0, 0] = 0
	x = 0
	y = 0
	ans = n + 1
	l = 0
	r = n + 1
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'D':
			y -= 1
		else:
			y += 1
		if (x, y) not in dict1.keys():
			dict1[x, y] = i + 1
		else:
			temp = dict1[x, y]
			if ans > i - temp + 1:
				ans = i - temp + 1
				l = temp + 1
				r = i + 1
			dict1[x, y] = i + 1
	if ans == n + 1:
		print(-1)
	else:
		print(l, r)


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	d = {(0, 0): 0}
	(x, y) = (0, 0)
	mn = n + 1
	for i in range(n):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			if i - d[x, y] < mn:
				st = d[x, y]
				ed = i
				mn = i - d[x, y]
		d[x, y] = i + 1
	if mn == n + 1:
		print(-1)
	else:
		print(st + 1, ed + 1, sep=' ')


def main():
	t = int(input().strip())
	for _ in range(t):
		n = int(input().strip())
		s = input().strip()
		(x, y) = (0, 0)
		d = {(0, 0): 0}
		(l, r) = (0, float('inf'))
		for (i, c) in enumerate(s, 1):
			if c == 'L':
				x -= 1
			elif c == 'R':
				x += 1
			elif c == 'U':
				y += 1
			else:
				y -= 1
			if (x, y) in d and i - d[x, y] < r - l:
				(l, r) = (d[x, y], i)
			d[x, y] = i
		if r < float('inf'):
			print(l + 1, r)
		else:
			print(-1)
main()


from collections import OrderedDict
for _ in range(int(input())):
	n = int(input())
	s = input()
	o = (0, 0)
	x = 0
	y = 0
	dict = {(0, 0): 0}
	sict = OrderedDict()
	l = []
	for i in range(1, n + 1):
		if s[i - 1] == 'L':
			x -= 1
		elif s[i - 1] == 'R':
			x += 1
		elif s[i - 1] == 'D':
			y -= 1
		elif s[i - 1] == 'U':
			y += 1
		if (x, y) not in dict.keys():
			dict[x, y] = i
		else:
			l.append((abs(dict[x, y] - i), dict[x, y] + 1, i))
			dict[x, y] = i
	if l == []:
		print(-1)
	else:
		l = sorted(l, key=lambda x: x[0])
		print(l[0][1], l[0][2])


n = int(input())
for i in range(n):
	m = float('inf')
	i1 = i2 = -1
	l = int(input())
	path = input()
	pos = (0, 0)
	hash = dict()
	hash[pos] = 0
	for (i, ch) in enumerate(path):
		i += 1
		if ch == 'R':
			pos = (pos[0] + 1, pos[1])
		elif ch == 'L':
			pos = (pos[0] - 1, pos[1])
		elif ch == 'U':
			pos = (pos[0], pos[1] + 1)
		else:
			pos = (pos[0], pos[1] - 1)
		if pos in hash:
			iprev = hash[pos]
			if i - iprev < m:
				m = i - iprev
				(i1, i2) = (iprev, i)
		hash[pos] = i
	print('{} {}'.format(i1 + 1, i2) if i1 != -1 else -1)


def f(i, n):
	return n + 1 + i
for q in range(int(input())):
	n = int(input())
	s = input()
	t_x = 0
	ans = 1e+20
	ANS = [-1]
	t_y = 0
	used = set()
	zn = dict()
	used.add((f(0, n), f(0, n)))
	zn[f(0, n)] = dict()
	zn[f(0, n)][f(0, n)] = -1
	for i in range(n):
		el = s[i]
		if el == 'L':
			t_x -= 1
		if el == 'R':
			t_x += 1
		if el == 'D':
			t_y -= 1
		if el == 'U':
			t_y += 1
		if (f(t_x, n), f(t_y, n)) in used:
			if ans > i - zn[f(t_x, n)][f(t_y, n)]:
				ans = i - zn[f(t_x, n)][f(t_y, n)]
				ANS = (zn[f(t_x, n)][f(t_y, n)] + 2, i + 1)
			zn[f(t_x, n)][f(t_y, n)] = i
		else:
			used.add((f(t_x, n), f(t_y, n)))
			if f(t_x, n) not in zn:
				zn[f(t_x, n)] = dict()
			zn[f(t_x, n)][f(t_y, n)] = i
	print(*ANS)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	dic = {(0, 0): -1}
	x = 0
	y = 0
	least_dist = -1
	least = (-1, -1)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) not in dic:
			dic[x, y] = i
		else:
			dist = i - dic[x, y]
			if least_dist > dist or least_dist == -1:
				least_dist = dist
				least = (dic[x, y] + 2, i + 1)
			if dist == 2:
				break
			dic[x, y] = i
	if least_dist == -1 or least[0] == least[1]:
		print(-1)
	else:
		print(least[0], least[1], sep=' ')


import sys
import math
from collections import defaultdict, Counter
t = int(input())
for i in range(t):
	n = int(input())
	d = {(0, 0): -1}
	s = input()
	x = 0
	y = 0
	ma = n + 1
	flag = 0
	for j in range(n):
		if s[j] == 'U':
			y += 1
		elif s[j] == 'D':
			y -= 1
		elif s[j] == 'R':
			x += 1
		else:
			x -= 1
		if (x, y) in d:
			flag = 1
			if j - d[x, y] < ma:
				ma = j - d[x, y]
				ans = [d[x, y] + 2, j + 1]
				if ma == 2:
					break
		d[x, y] = j
	if flag == 0:
		print(-1)
	else:
		print(*ans)


T = int(input())
for t in range(T):
	(n,) = map(int, input().split())
	dirs = input()
	(x, y) = (0, 0)
	coordToIndex = {}
	coordToIndex[x, y] = -1
	best = (float('inf'),)
	for (i, c) in enumerate(dirs):
		if c == 'L':
			(x, y) = (x - 1, y)
		if c == 'R':
			(x, y) = (x + 1, y)
		if c == 'U':
			(x, y) = (x, y + 1)
		if c == 'D':
			(x, y) = (x, y - 1)
		if (x, y) in coordToIndex:
			best = min(best, (i - coordToIndex[x, y], coordToIndex[x, y], i))
		coordToIndex[x, y] = i
	if best[0] != float('inf'):
		print(best[1] + 2, best[2] + 1)
	else:
		print(-1)


t = int(input())
for tc in range(t):
	coors = {}
	coors[0, 0] = 0
	n = int(input())
	d = input().rstrip()
	(x, y) = (0, 0)
	possible = []
	mindist = 10 ** 9
	opl = -1
	opr = -1
	for i in range(n):
		direct = d[i]
		if direct == 'U':
			if (x, y + 1) in coors:
				if mindist > i + 1 - coors[x, y + 1]:
					opl = coors[x, y + 1]
					opr = i
					mindist = opr - opl + 1
			coors[x, y + 1] = i + 1
			y += 1
		elif direct == 'D':
			if (x, y - 1) in coors:
				if mindist > i + 1 - coors[x, y - 1]:
					opl = coors[x, y - 1]
					opr = i
					mindist = opr - opl + 1
			coors[x, y - 1] = i + 1
			y -= 1
		elif direct == 'R':
			if (x + 1, y) in coors:
				if mindist > i + 1 - coors[x + 1, y]:
					opl = coors[x + 1, y]
					opr = i
					mindist = opr - opl + 1
			coors[x + 1, y] = i + 1
			x += 1
		elif direct == 'L':
			if (x - 1, y) in coors:
				if mindist > i + 1 - coors[x - 1, y]:
					opl = coors[x - 1, y]
					opr = i
					mindist = opr - opl + 1
			coors[x - 1, y] = i + 1
			x -= 1
	if opl == opr == -1:
		print(-1)
		continue
	opr += 1
	opl += 1
	print(opl, opr)


t = int(input())
for i in range(t):
	n = int(input())
	p = input()
	l = -1
	r = n
	path = [0, 0]
	visited = {(0, 0): 0}
	for j in range(n):
		if p[j] == 'L':
			path[0] -= 1
		elif p[j] == 'R':
			path[0] += 1
		elif p[j] == 'D':
			path[1] -= 1
		elif p[j] == 'U':
			path[1] += 1
		if tuple(path) in visited:
			if j - visited[tuple(path)] < r - l:
				l = visited[tuple(path)]
				r = j
		visited[tuple(path)] = j + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


T = int(input())
t = 0
while t < T:
	l = int(input())
	s = input()
	x = 0
	y = 0
	ris = float('INF')
	f = False
	P = {(x, y): 0}
	n = 0
	a = l
	b = l
	while n < l:
		c = s[n]
		if c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		elif c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		if (x, y) in P:
			if n + 1 - P[x, y] < ris:
				a = P[x, y] + 1
				b = n + 1
				ris = n + 1 - P[x, y]
				f = True
		P[x, y] = n + 1
		n += 1
	if f:
		print(a, b)
	else:
		print(-1)
	t += 1


from collections import defaultdict as dc
from heapq import *
import math
import bisect
from collections import deque as dq

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

def line():
	p = list(map(int, input().split()))
	return p

def check(n, d, x):
	if x < 0:
		return 0
	return n >= x + math.ceil(d / (x + 1))

def unique(s, n):
	p = []
	d = dc(int)
	(x, y) = (0, 0)
	(l, r, z1) = (0, 0, float('inf'))
	z = s.find('LR')
	if z != -1:
		return (z + 1, z + 2)
	z = s.find('RL')
	if z != -1:
		return (z + 1, z + 2)
	z = s.find('UD')
	if z != -1:
		return (z + 1, z + 2)
	z = s.find('DU')
	if z != -1:
		return (z + 1, z + 2)
	d[0, 0] = 1
	for i in range(n):
		if s[i] == 'L':
			x = x - 1
		elif s[i] == 'R':
			x = x + 1
		elif s[i] == 'U':
			y = y - 1
		else:
			y = y + 1
		if d[x, y] != 0 and z1 > i - d[x, y]:
			l = d[x, y]
			r = i + 1
			z1 = r - l
		d[x, y] = i + 2
	if z1 == float('inf'):
		return -1
	else:
		return (l, r)

def form(h, n, x):
	if abs(h - n) % x == 0:
		return 1
	return 0
for _ in range(int(input())):
	n = int(input())
	s = str(input())
	z = unique(s, n)
	if z == -1:
		print(-1)
	else:
		print(*z)


import sys, math
input = sys.stdin.readline

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

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

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

def invr():
	return map(int, input().split())
t = 1
t = inp()
for tt in range(t):
	n = inp()
	a = insr()
	if len(a) > 1 and a[0] == 'D' and (a[1] == 'U'):
		print(1, 2)
		continue
	s = [[0, 0] for i in range(len(a))]
	q = 0
	w = 0
	for i in range(len(a)):
		if a[i] == 'U':
			q = q + 1
		elif a[i] == 'D':
			q = q - 1
		elif a[i] == 'L':
			w = w - 1
		elif a[i] == 'R':
			w = w + 1
		s[i][0] = w
		s[i][1] = q
	q = {}
	qwqw = -1
	s = [str(i) for i in s]
	if '[0, 0]' in s:
		qwqw = s.index('[0, 0]')
	for i in range(len(s)):
		q[str(s[i])] = []
	for i in range(len(s)):
		q[str(s[i])] = q.get(str(s[i])) + [i]
	s = list(set(s))
	qw = 9999999999
	ww = []
	c = 0
	for i in range(len(q)):
		w = q.get(s[i])
		ww.append(len(w))
		for j in range(len(w) - 1):
			if 1 <= w[j + 1] - w[j] < qw:
				qw = w[j + 1] - w[j]
				qq = [w[j] + 2, w[j + 1] + 1]
			c = c + 1
	if qwqw != -1 and qwqw <= qw:
		print(1, qwqw + 1)
	elif len(set(ww)) == 1 and ww[0] == 1:
		print(-1)
	else:
		print(*qq)


t = int(input())
while t > 0:
	t = t - 1
	n = int(input())
	s = input()
	d = {(0, 0): 0}
	(x, y) = (0, 0)
	f = 0
	l = 0
	r = 10001000100
	for i in range(len(s)):
		if s[i] == 'L':
			x = x - 1
		elif s[i] == 'R':
			x = x + 1
		elif s[i] == 'U':
			y = y - 1
		elif s[i] == 'D':
			y = y + 1
		if (x, y) in d:
			if i + 1 - (d[x, y] + 1) < r - l:
				l = d[x, y] + 1
				r = i + 1
				f = 1
		d[x, y] = i + 1
	if f == 0:
		print(-1)
	else:
		print(l, r)


for _ in range(int(input())):
	minim = 2000000
	pair = []
	mydict = {(0, 0): 1}
	length = int(input())
	arr = list(input())
	(currentx, currenty) = (0, 0)
	for (step, direction) in enumerate(arr):
		if direction == 'U':
			(currentx, currenty) = (currentx, currenty + 1)
		elif direction == 'D':
			(currentx, currenty) = (currentx, currenty - 1)
		elif direction == 'R':
			(currentx, currenty) = (currentx + 1, currenty)
		elif direction == 'L':
			(currentx, currenty) = (currentx - 1, currenty)
		if (currentx, currenty) in mydict:
			dist = step + 1 - mydict[currentx, currenty]
			if dist < minim:
				minim = dist
				pair = [mydict[currentx, currenty], step + 1]
		mydict[currentx, currenty] = step + 2
	if pair:
		print(*pair)
	else:
		print(-1)


from collections import defaultdict
t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	(ansl, ansr) = (-1, n)
	d = defaultdict(int)
	(x, y) = (0, 0)
	d[x, y] = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if x == 0 and y == 0 or d[x, y] != 0:
			if i + 1 - d[x, y] < ansr + 1 - ansl:
				ansr = i
				ansl = d[x, y]
		d[x, y] = i + 1
	if ansl == -1:
		print('-1')
	else:
		print(ansl + 1, ansr + 1)


num_t = int(input())
for _ in range(num_t):
	input()
	path = input()
	diff = float('inf')
	l = r = None
	last = {(0, 0): -1}
	(x, y) = (0, 0)
	for (i, m) in enumerate(path):
		if m == 'L':
			x -= 1
		elif m == 'R':
			x += 1
		elif m == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in last:
			last_i = last[x, y]
			if i - last_i < diff:
				l = last_i
				r = i
				diff = i - last_i
		last[x, y] = i
	if l == None:
		print(-1)
	else:
		l += 1
		r += 1
		print(l + 1, r)


from collections import defaultdict
from os import system
import sys
import queue

def dist(x):
	return abs(x[0] ** 2 + x[1] ** 2)
for _ in range(int(input())):
	n = int(input())
	path = input()
	arr = []
	curr = [0, 0]
	carry = defaultdict(list)
	flag = True
	carry[0, 0].append(-1)
	for i in range(len(path)):
		if path[i] == 'L':
			curr[0] -= 1
		elif path[i] == 'R':
			curr[0] += 1
		elif path[i] == 'U':
			curr[1] += 1
		elif path[i] == 'D':
			curr[1] -= 1
		carry[curr[0], curr[1]].append(i)
	vals = []
	for (x, y) in carry.items():
		if len(y) > 1:
			for i in range(len(y) - 1):
				vals.append((abs(y[i] - y[i + 1]), (y[i], y[i + 1])))
	vals.sort(key=lambda x: x[0])
	if len(vals) == 0:
		print(-1)
	else:
		print(vals[0][1][0] + 2, '', vals[0][1][1] + 1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	p = [i for i in input()]
	pos = [0, 0]
	s = set()
	s.add(tuple(pos))
	dist = 1e+18
	ans = [-1]
	d = defaultdict(int)
	d[tuple(pos)] = 0
	for i in range(n):
		if p[i] == 'R':
			pos[0] += 1
		if p[i] == 'L':
			pos[0] -= 1
		if p[i] == 'U':
			pos[1] += 1
		if p[i] == 'D':
			pos[1] -= 1
		if tuple(pos) in s:
			if i - d[tuple(pos)] < dist:
				dist = i - d[tuple(pos)]
				ans = [d[tuple(pos)] + 1, i + 1]
		else:
			s.add(tuple(pos))
		d[tuple(pos)] = i + 1
	print(*ans)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	d = {(0, 0): -1}
	t = (-1, -1)
	mini = 10000000
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) not in d:
			d[x, y] = i
		else:
			dis = i - d[x, y]
			if mini > dis:
				mini = dis
				t = (d[x, y] + 2, i + 1)
			if dis == 2:
				break
			d[x, y] = i
	if mini == 10000000:
		print('-1')
	else:
		print(*t)


import math
from collections import defaultdict, Counter, deque
INF = float('inf')

def gcd(a, b):
	while b:
		(a, b) = (b, a % b)
	return a

def primeFactor(n):
	if n % 2 == 0:
		return 2
	i = 3
	while i ** 2 <= n:
		if n % i == 0:
			return i
		i += 1
	return n

def main():
	n = int(input())
	d = input()
	posx = 0
	posy = 0
	m = {(0, 0): 1}
	res = INF
	a = INF
	ans = -1
	for i in range(n):
		if d[i] == 'L':
			posx -= 1
		elif d[i] == 'R':
			posx += 1
		elif d[i] == 'U':
			posy += 1
		else:
			posy -= 1
		if (posx, posy) in m:
			res = i + 1 - m[posx, posy] + 1
			if a > res:
				a = res
				ans = (m[posx, posy], i + 1)
		m[posx, posy] = i + 2
	if ans != -1:
		print(*ans)
	else:
		print(-1)
t = int(input())
for _ in range(t):
	main()


for _ in range(int(input())):
	n = int(input())
	d = list(input())
	(xe, ye) = (0, 0)
	hmap = {}
	temp = str(xe) + ' ' + str(ye)
	count = 0
	hmap[temp] = count
	minz = n + 2
	ans = None
	for i in d:
		count += 1
		if i == 'L':
			xe -= 1
		elif i == 'R':
			xe += 1
		elif i == 'U':
			ye += 1
		elif i == 'D':
			ye -= 1
		temp = str(xe) + ' ' + str(ye)
		if temp in hmap.keys():
			if minz > count - hmap[temp]:
				minz = count - hmap[temp]
				ans = [hmap[temp], count]
			hmap[temp] = count
		else:
			hmap[temp] = count
	if ans == None:
		print(-1)
	else:
		print(ans[0] + 1, ans[1])


for _ in range(int(input())):
	input()
	steps = input()
	visited = {0: {0: -1}}
	pos_x = 0
	pos_y = 0
	res = None
	min_length = None
	for (i, s) in enumerate(steps):
		if s == 'L':
			pos_x -= 1
		if s == 'R':
			pos_x += 1
		if s == 'U':
			pos_y += 1
		if s == 'D':
			pos_y -= 1
		start = None
		if visited.get(pos_x):
			start = visited.get(pos_x).get(pos_y)
		if start != None:
			path_length = i - start
			if min_length == None or path_length < min_length:
				if start == -1:
					res = f'{1} {i + 1}'
				else:
					res = f'{start + 2} {i + 1}'
				min_length = path_length
		visited[pos_x] = visited.get(pos_x, {})
		visited[pos_x][pos_y] = i
	if res:
		print(res)
	else:
		print(-1)


import sys
import math
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = list()
	x = 0
	y = 0
	for i in range(n):
		if s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		l.append([x, y])
	dc = dict()
	ans = 100000000
	le = 0
	r = 0
	dc['0@0'] = 0
	for i in range(len(l)):
		s1 = str(l[i][0])
		s2 = str(l[i][1])
		s = s1 + '@' + s2
		if s in dc.keys():
			if i + 1 - dc[s] < ans:
				ans = i + 1 - dc[s]
				le = dc[s] + 1
				r = i + 1
		dc[s] = i + 1
	if ans > 1000000:
		print(-1)
	else:
		print(le, r)


import sys
sys.setrecursionlimit(10 ** 6)
from sys import stdin, stdout
import math
from collections import defaultdict, Counter, deque
from functools import lru_cache
from bisect import bisect, bisect_left
from heapq import heapify, heappush, heappop, heappushpop
from itertools import permutations, combinations
mod = 10 ** 9 + 7
inf = math.inf

def solve(s):
	moves = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
	mn_dis = inf
	(l, r) = (None, None)
	(x, y) = (0, 0)
	seen = {(0, 0): 0}
	for i in range(n):
		(dx, dy) = moves[s[i]]
		(x, y) = (x + dx, y + dy)
		if (x, y) in seen:
			j = seen[x, y]
			if i - j < mn_dis:
				mn_dis = i - j
				(l, r) = (j, i)
		seen[x, y] = i + 1
	if mn_dis == inf:
		print(-1)
		return
	print(l + 1, r + 1)
	return
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	solve(s)


for _ in range(int(input())):
	n = int(input())
	s = str(input()).upper()
	a = [0, 0]
	d = {}
	d[tuple(a)] = -1
	l = -1
	r = n
	for i in range(n):
		if s[i] == 'L':
			a[0] -= 1
		elif s[i] == 'R':
			a[0] += 1
		elif s[i] == 'D':
			a[1] -= 1
		elif s[i] == 'U':
			a[1] += 1
		if tuple(a) in d and r - l + 1 > i - d[tuple(a)]:
			l = d[tuple(a)] + 1
			r = i
		d[tuple(a)] = i
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	d = {(0, 0): [1, 1]}
	d1 = {}
	d = defaultdict(lambda : [0, 0], d)
	s = [0, 0]
	n = int(input())
	s1 = input()
	arr = []
	k = 1
	for i in s1:
		if i == 'L':
			s[0] -= 1
		elif i == 'R':
			s[0] += 1
		elif i == 'U':
			s[1] += 1
		else:
			s[1] -= 1
		if d[s[0], s[1]][0] == 1:
			arr.append([k - d[s[0], s[1]][1], d[s[0], s[1]][1], k])
		d[s[0], s[1]] = [1, k + 1]
		k += 1
	if len(arr) == 0:
		print(-1)
	else:
		arr = sorted(arr)
		print(arr[0][1], arr[0][2])


def solve():
	lenth = int(input())
	command = input()
	l = -1
	r = lenth
	dic = {}
	curx = 0
	cury = 0
	dic[curx, cury] = 0
	for i in range(lenth):
		if command[i] == 'L':
			curx -= 1
		if command[i] == 'R':
			curx += 1
		if command[i] == 'U':
			cury += 1
		if command[i] == 'D':
			cury -= 1
		if (curx, cury) in dic.keys():
			if i - dic[curx, cury] + 1 < r - l + 1:
				l = dic[curx, cury]
				r = i
		dic[curx, cury] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)
T = int(input())
for _ in range(T):
	solve()


for _ in range(int(input())):
	n = int(input())
	s = input()
	path = {}
	(x, y) = (0, 0)
	minn = 2 ** 31
	path[0, 0] = 0
	(start, end) = (0, 0)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y -= 1
		if s[i] == 'D':
			y += 1
		if (x, y) not in path.keys():
			path[x, y] = i + 1
		else:
			if i + 1 - path[x, y] < minn:
				(start, end) = (path[x, y], i + 1)
				minn = i + 1 - path[x, y]
			path[x, y] = i + 1
	if start == 0 and end == 0:
		print(-1)
	else:
		print(start + 1, end)


from itertools import permutations
from collections import *
for i in range(int(input())):
	(n, s) = (int(input()), input())
	(visit, dis, cur) = (defaultdict(int, {(0, 0): 0}), defaultdict(lambda : [0, 1000000000000]), [0, 0])
	for j in range(1, n + 1):
		if s[j - 1] == 'L':
			cur[0] -= 1
		elif s[j - 1] == 'R':
			cur[0] += 1
		elif s[j - 1] == 'U':
			cur[1] += 1
		else:
			cur[1] -= 1
		cur1 = tuple(cur)
		if visit[cur1] or cur1 == (0, 0):
			(tem, tem1) = (dis[cur1][1] - dis[cur1][0], j - visit[cur1])
			if tem1 < tem:
				dis[cur1] = [visit[cur1] + 1, j]
		visit[cur1] = j
	ans = float('inf')
	for j in dis.keys():
		if ans == float('inf'):
			ans = dis[j]
		elif dis[j][1] - dis[j][0] < ans[1] - ans[0]:
			ans = dis[j]
	if ans == float('inf'):
		print(-1)
	else:
		print(*ans)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	hor = 0
	ver = 0
	minim = 1000000
	sml = 0
	lar = 0
	prev = {}
	prev[0, 0] = 0
	for ind in range(len(s)):
		i = s[ind]
		if i == 'L':
			hor -= 1
			x = (hor, ver)
		elif i == 'R':
			hor += 1
			x = (hor, ver)
		elif i == 'U':
			ver += 1
			x = (hor, ver)
		else:
			ver -= 1
			x = (hor, ver)
		if x not in prev:
			prev[x] = ind + 1
		else:
			if ind + 1 - prev[x] < minim:
				minim = ind + 1 - prev[x]
				sml = prev[x]
				lar = ind + 1
			prev[x] = ind + 1
	if minim < 1000000:
		print(str(sml + 1) + ' ' + str(lar))
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	ans = ''
	minStr = {'id': -1, 'length': len(s)}
	cords = {(0, 0): 0}
	actCords = {'x': 0, 'y': 0}
	for i in range(len(s)):
		symb = s[i]
		if symb == 'L':
			actCords['x'] -= 1
		elif symb == 'R':
			actCords['x'] += 1
		elif symb == 'U':
			actCords['y'] += 1
		else:
			actCords['y'] -= 1
		arCords = (actCords['x'], actCords['y'])
		if cords.get(arCords) != None and i - cords[arCords] < minStr['length']:
			minStr['id'] = cords[arCords]
			minStr['length'] = i - cords[arCords]
		cords[arCords] = i + 1
	if minStr['id'] == -1:
		print(-1)
	else:
		print(minStr['id'] + 1, minStr['id'] + minStr['length'] + 1)


N_tests = int(input())
for test in range(N_tests):
	N_moves = int(input())
	moves = input()
	Position = {(0, 0): 0}
	(x, y, l, r, lr) = (0, 0, 0, 0, 0)
	for i in range(0, N_moves):
		move = moves[i]
		if move == 'L':
			x -= 1
		elif move == 'R':
			x += 1
		elif move == 'U':
			y += 1
		elif move == 'D':
			y -= 1
		if Position.__contains__((x, y)):
			length = i - Position[x, y]
			if lr == 0:
				l = Position[x, y] + 1
				r = i + 1
				lr = length
			elif length < lr:
				l = Position[x, y] + 1
				r = i + 1
				lr = length
		Position[x, y] = i + 1
	if lr == 0:
		print('-1')
	else:
		print('%d %d' % (l, r))


inf = float('inf')
tests = int(input())
for x in range(tests):
	dlzka = int(input())
	string = input()
	(count, x, y, najmenej, ans_1, ans_2) = [1, 0, 0, inf, -1, -1]
	dic = {}
	dic[0, 0] = 0
	for i in range(dlzka):
		if string[i] == 'L':
			x -= 1
		elif string[i] == 'R':
			x += 1
		elif string[i] == 'U':
			y -= 1
		elif string[i] == 'D':
			y += 1
		if (x, y) not in dic:
			dic[x, y] = count
		else:
			if count - dic[x, y] < najmenej:
				ans_1 = dic[x, y]
				ans_2 = count
				najmenej = count - dic[x, y]
			dic[x, y] = count
		count += 1
	if ans_1 == -1:
		print(-1)
	else:
		print(ans_1 + 1, ans_2)


testcases = int(input())
for k in range(testcases):
	n = int(input())
	rstrings = list(input())
	coords = {}
	coords[0, 0] = 1
	indices = {}
	x = 0
	y = 0
	cv = 0
	smallestsofar = n + 1
	smallestslice = [0]
	exists = False
	while cv <= n - 1:
		if not (x, y) in indices:
			indices[x, y] = []
			indices[x, y].append(cv)
		else:
			indices[x, y].append(cv)
		if rstrings[cv] == 'R':
			x += 1
		elif rstrings[cv] == 'L':
			x += -1
		elif rstrings[cv] == 'U':
			y += 1
		elif rstrings[cv] == 'D':
			y += -1
		if not (x, y) in coords:
			coords[x, y] = 1
		elif (x, y) in coords:
			coords[x, y] += 1
		if coords[x, y] >= 2:
			exists = True
			i = indices[x, y][-1]
			if cv - i < smallestsofar:
				smallestsofar = cv - i
				smallestslice[0] = (i, cv)
		cv += 1
	if exists == True:
		print(str(smallestslice[0][0] + 1) + ' ' + str(smallestslice[0][1] + 1))
	else:
		print(-1)


from collections import defaultdict
import sys
input = sys.stdin.readline

def case():
	n = int(input())
	s = input().strip()
	t = 1
	(x, y) = (0, 0)
	d = defaultdict(list)
	d[0, 0].append(0)
	anslen = 10 ** 10
	ans = []
	for i in s:
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'D':
			y -= 1
		elif i == 'U':
			y += 1
		if d[x, y] != []:
			if t - d[x, y][-1] < anslen:
				anslen = t - d[x, y][-1]
				ans = [d[x, y][-1], t]
		d[x, y].append(t)
		t += 1
	if anslen == 10 ** 10:
		print(-1)
	else:
		print(ans[0] + 1, ans[1])
for _ in range(int(input())):
	case()


for t in range(int(input())):
	n = int(input())
	s = input()
	x = y = 0
	m = {(x, y): 0}
	left = right = -1
	check = False
	lnn = float('+inf')
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in m:
			ln = i - m[x, y] + 1
			if ln < lnn:
				lnn = ln
				left = m[x, y] + 1
				right = i + 1
			check = True
		m[x, y] = i + 1
	if check:
		print(left, right)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(dx, dy) = ({'L': -1, 'R': 1, 'U': 0, 'D': 0}, {'L': 0, 'R': 0, 'U': 1, 'D': -1})
	(x, y, ax, ay) = (0, 0, 0, 0)
	mx = 10 ** 9
	d = {(0, 0): 0}
	for i in range(n):
		x += dx[s[i]]
		y += dy[s[i]]
		if (x, y) in d:
			j = d[x, y]
			if i + 1 - j < mx:
				mx = i + 1 - j
				(ax, ay) = (j + 1, i + 1)
		d[x, y] = i + 1
	if mx == 10 ** 9:
		print(-1)
	else:
		print(ax, ay)


from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = list(input().strip())
	dct = {(0, 0): -1}
	(x, y) = (0, 0)
	ml = n + 1
	ri = li = None
	for (i, c) in enumerate(s):
		if c == 'L':
			x -= 1
		if c == 'R':
			x += 1
		if c == 'U':
			y += 1
		if c == 'D':
			y -= 1
		if (x, y) in dct:
			j = dct[x, y]
			if i - j < ml:
				ml = i - j
				li = j + 2
				ri = i + 1
		dct[x, y] = i
	if ml <= n:
		print(li, ri)
	else:
		print(-1)


t = int(input())
for y in range(t):
	n = int(input())
	s = input()
	pre = [0 for i in range(n + 1)]
	for i in range(n):
		if s[i] == 'L':
			pre[i + 1] = pre[i] + 1
		elif s[i] == 'R':
			pre[i + 1] = pre[i] - 1
		elif s[i] == 'U':
			pre[i + 1] = pre[i] + int(1000000.0)
		else:
			pre[i + 1] = pre[i] - int(1000000.0)
	d = dict()
	ans = -1
	l = r = -1
	for i in range(n + 1):
		if pre[i] not in d:
			d[pre[i]] = i
		else:
			if ans == -1 or i - d[pre[i]] < ans:
				ans = i - d[pre[i]]
				l = d[pre[i]] + 1
				r = i
			d[pre[i]] = i
	if ans == -1:
		print(ans)
	else:
		print(l, r)


for _ in range(int(input())):
	n = int(input())
	a = input()
	ma = n + 2
	ans = -1
	x = 0
	y = 0
	dic = {(0, 0): 0}
	for i in range(len(a)):
		if a[i] == 'L':
			x -= 1
		elif a[i] == 'R':
			x += 1
		if a[i] == 'U':
			y += 1
		if a[i] == 'D':
			y -= 1
		if (x, y) in dic.keys():
			if i - dic[x, y] + 1 < ma:
				an = [dic[x, y] + 1, i + 1]
				ma = i - dic[x, y]
				ans = 1
		dic[x, y] = i + 1
	if ans != -1:
		print(*an)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = 0
	y = 0
	d = {}
	d[0, 0] = [-1]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d.keys():
			d[x, y].append(i)
		else:
			d[x, y] = [i]
	l = -1
	r = -1
	minn = 10 ** 9
	for key in d.keys():
		if len(d[key]) > 1:
			for i in range(len(d[key]) - 1):
				if d[key][i + 1] - d[key][i] < minn:
					l = d[key][i] + 2
					r = d[key][i + 1] + 1
					minn = d[key][i + 1] - d[key][i]
	if minn == 10 ** 9:
		print('-1')
	else:
		print(l, r)


for j in range(int(input())):
	x = int(input())
	s = input()
	f = 0
	doc = {}
	dicti = {}
	(p, q) = (0, 0)
	doc[0, 0] = 0
	for i in range(0, len(s)):
		if s[i] == 'L':
			p -= 1
		elif s[i] == 'R':
			p += 1
		elif s[i] == 'U':
			q += 1
		else:
			q -= 1
		if doc.get((p, q)) == None:
			doc[p, q] = i + 1
		else:
			dicti[i - doc[p, q]] = [doc[p, q], i]
			doc[p, q] = i + 1
	if not bool(dicti):
		print(-1)
	else:
		for (key, value) in sorted(dicti.items()):
			print(value[0] + 1, value[1] + 1)
			break


x = pow(10, 6)
t = int(input())
from collections import Counter
for i in range(t):
	n = int(input())
	s = input()
	c = Counter([])
	mini = 9999999999999
	sumi = 0
	for j in range(len(s)):
		if s[j] == 'L':
			sumi -= 1
		elif s[j] == 'R':
			sumi += 1
		elif s[j] == 'U':
			sumi += x
		else:
			sumi -= x
		if sumi == 0:
			if j + 1 < mini:
				mini = j + 1
				a = 1
				b = j + 1
		if c[sumi] == 0:
			c[sumi] = j + 1
		else:
			if j + 1 - c[sumi] < mini:
				a = c[sumi] + 1
				b = j + 1
				mini = j + 1 - c[sumi] + 1
			c[sumi] = j + 1
	if mini == 9999999999999:
		print(-1)
	else:
		print(a, end=' ')
		print(b)


import sys
read = lambda : list(map(int, sys.stdin.readline().strip().split()))
(mapp1, mapp2) = ({'L': -1, 'R': 1, 'U': 0, 'D': 0}, {'L': 0, 'R': 0, 'U': 1, 'D': -1})
for _ in range(int(input())):
	n = int(input())
	pos = {(0, 0): -1}
	ans = [-1, -1, 10 ** 9]
	now = [0, 0]
	path = input()
	for (ind, i) in enumerate(path):
		now[0] += mapp1[i]
		now[1] += mapp2[i]
		temp = tuple(now)
		if temp in pos:
			(l, r) = (pos[temp], ind)
			if r - l + 1 < ans[2]:
				ans = [l, r, r - l + 1]
		pos[temp] = ind
	if ans[2] == 10 ** 9:
		print(-1)
	else:
		print(ans[0] + 2, ans[1] + 1)


for q in range(int(input())):
	n = int(input())
	d = input()
	dic = {(0, 0): [0]}
	curr = [0, 0]
	for i in range(n):
		l = d[i]
		if l == 'L':
			curr[0] -= 1
		elif l == 'R':
			curr[0] += 1
		elif l == 'D':
			curr[1] -= 1
		else:
			curr[1] += 1
		tp = tuple(curr)
		if tp in dic:
			dic[tp].append(i + 1)
		else:
			dic[tp] = [i + 1]
	mn = 300000
	mnv = [-1, -1]
	for vl in dic.values():
		for i in range(len(vl) - 1):
			v = vl[i + 1] - vl[i]
			if v < mn:
				mn = v
				mnv[0] = vl[i]
				mnv[1] = vl[i + 1]
	if mn == 300000:
		print(-1)
	else:
		print(mnv[0] + 1, mnv[1])


from collections import defaultdict
from sys import stdin
input = stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	c = 0
	l = []
	(x, y) = (0, 0)
	l = dict()
	l[tuple([x, y])] = 0
	ll = []
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if tuple([x, y]) in l:
			j = l[tuple([x, y])]
			ll.append([abs(j - i), j + 1, i + 1])
			if ll[-1][2] - ll[-1][1] == 1:
				print(j + 1, i + 1)
				c = 1
				break
		l[tuple([x, y])] = i + 1
	if c != 1:
		if len(ll) > 0:
			ll.sort()
			print(ll[0][1], ll[0][2])
		else:
			print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	(x, y) = [0, 0]
	um = {}
	um['0_0'] = 0
	(resx, resy, resl) = [0, 0, n + 1]
	for i in range(len(s)):
		if s[i] == 'L':
			x = x - 1
		elif s[i] == 'R':
			x = x + 1
		elif s[i] == 'U':
			y = y + 1
		else:
			y = y - 1
		if str(x) + '_' + str(y) not in um:
			um[str(x) + '_' + str(y)] = i + 1
		else:
			if i + 1 - um[str(x) + '_' + str(y)] < resl:
				resx = um[str(x) + '_' + str(y)] + 1
				resy = i + 1
				resl = i + 1 - um[str(x) + '_' + str(y)]
			um[str(x) + '_' + str(y)] = i + 1
	if resl == n + 1:
		print('-1')
	else:
		print(str(resx) + ' ' + str(resy))


t = int(input())
for i in range(t):
	l = -1
	n = int(input())
	r = n
	s = input().strip()
	x_y = [0, 0]
	X = {}
	X[tuple(x_y)] = 0
	for i in range(n):
		if s[i] == 'R':
			x_y[0] += 1
		elif s[i] == 'L':
			x_y[0] -= 1
		elif s[i] == 'U':
			x_y[1] += 1
		elif s[i] == 'D':
			x_y[1] -= 1
		if tuple(x_y) in X:
			if i - X[tuple(x_y)] + 1 < r - l + 1:
				l = X[tuple(x_y)]
				r = i
		X[tuple(x_y)] = i + 1
	if l == -1:
		print(l)
	else:
		print(l + 1, r + 1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	li = {(0, 0): 0}
	(x, y) = (0, 0)
	sol = []
	len = 1000000000000
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in li:
			len = min(len, i + 1 - li[x, y] - 1)
			if len == i + 1 - li[x, y] - 1:
				sol = [li[x, y] + 1, i + 1]
			li[x, y] = i + 1
		else:
			li[x, y] = i + 1
	if sol:
		print(*sol)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(l, r) = (0, n)
	p = (0, 0)
	d = {p: 1}
	index = 1
	for v in s:
		if v == 'L':
			p = (p[0] - 1, p[1])
		elif v == 'R':
			p = (p[0] + 1, p[1])
		elif v == 'U':
			p = (p[0], p[1] + 1)
		else:
			p = (p[0], p[1] - 1)
		if p in d and index - d[p] < r - l:
			(l, r) = (d[p], index)
		index += 1
		d[p] = index
	if l:
		print(l, r)
	else:
		print(-1)


def calc(n, s):
	(kv, res_min, res) = ({(0, 0): 0}, len(s) + 1, None)
	move = {'R': (1, 0), 'L': (-1, 0), 'D': (0, -1), 'U': (0, 1)}
	pos = (0, 0)
	for (i, m) in enumerate(s):
		pos = (pos[0] + move[m][0], pos[1] + move[m][1])
		if pos in kv:
			cur_min = i - kv[pos] + 1
			if res_min > cur_min:
				res_min = cur_min
				res = (kv[pos] + 1, i + 1)
		kv[pos] = i + 1
	if res:
		return (res[0], res[1])
	return (None, -1)
N = int(input())
cases = []
for _ in range(N):
	n = input()
	c = input()
	cases.append((n, c))
for (n, c) in cases:
	(i, j) = calc(n, c)
	if j == -1:
		print(-1)
	else:
		print(i, j)


t = int(input())
while t:
	t -= 1
	n = int(input())
	A = input()
	(X, Y) = (0, 0)
	c = -2
	l = []
	dic = dict()
	dic[X, Y] = 0
	m = n
	j = 1
	(xx, yy) = (0, 0)
	for i in range(n):
		if A[i] == 'R':
			X += 1
		elif A[i] == 'L':
			X -= 1
		elif A[i] == 'D':
			Y -= 1
		else:
			Y += 1
		if (X, Y) in dic:
			c = dic[X, Y]
			dic[X, Y] = i + 1
			if m > abs(i - c):
				xx = c + 1
				yy = i + 1
				m = abs(i - c)
		else:
			dic[X, Y] = i + 1
	if c == -2:
		print(-1)
	else:
		print(xx, yy)


import sys
input = lambda : sys.stdin.readline().strip('\r\n')
dir = {'U': (0, 1), 'D': (0, -1), 'L': (-1, 0), 'R': (1, 0)}
for _ in range(int(input())):
	n = int(input())
	s = input()
	vis = {(0, 0): 0}
	cur = (0, 0)
	ans = 1000000.0
	l = -1
	r = n
	for i in range(n):
		nxt = (cur[0] + dir[s[i]][0], cur[1] + dir[s[i]][1])
		if nxt in vis:
			if i - vis[nxt] + 1 < r - l + 1:
				l = vis[nxt]
				r = i
		vis[nxt] = i + 1
		cur = nxt
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


t = int(input())
for j in range(t):
	n = int(input())
	lis = list(input())
	x = 0
	y = 0
	d = {}
	d[x, y] = 0
	l = -1
	r = n
	for i in range(n):
		if lis[i] == 'R':
			y += 1
		elif lis[i] == 'L':
			y -= 1
		elif lis[i] == 'U':
			x += 1
		elif lis[i] == 'D':
			x -= 1
		if (x, y) in d:
			if i - d[x, y] < r - l:
				r = i
				l = d[x, y]
		d[x, y] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


def cal(x, y):
	return x * 47196412 + y

def rua():
	mp = {}
	n = int(input())
	s = input()
	ans = n + 1
	x = 0
	y = 0
	s1 = -1
	s2 = -1
	l = cal(x, y)
	mp[l] = 1
	i = 0
	for j in s:
		i = i + 1
		if j == 'U':
			y = y + 1
		elif j == 'D':
			y = y - 1
		elif j == 'L':
			x = x - 1
		elif j == 'R':
			x = x + 1
		l = cal(x, y)
		if l in mp:
			tmp = i + 1 - mp[l]
			if tmp < ans:
				ans = tmp
				s1 = mp[l]
				s2 = i
		mp[l] = i + 1
	if ans == n + 1:
		print(-1)
	else:
		print(s1, s2)
t = int(input())
while t:
	rua()
	t = t - 1


t = int(input())
for _ in range(t):
	n = int(input())
	x = 0
	y = 0
	s = input()
	d = {}
	d[0, 0] = -1
	g = []
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) not in d:
			d[x, y] = i
		else:
			g.append([i - d[x, y] - 1, d[x, y] + 2, i + 1])
			d[x, y] = i
	g.sort()
	if len(g) == 0:
		print(-1)
	else:
		print(g[0][1], g[0][2])


def calc(a):
	minn1 = min(a[0:2])
	minn2 = min(a[2:])
	return [a[0] - minn1, a[1] - minn1, a[2] - minn2, a[3] - minn2]
for nt in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	ans = 10 ** 18
	state = [0, 0, 0, 0]
	d[tuple(state)] = 0
	for i in range(n):
		if s[i] == 'L':
			state[0] += 1
		elif s[i] == 'R':
			state[1] += 1
		elif s[i] == 'U':
			state[2] += 1
		else:
			state[3] += 1
		if tuple(calc(state)) in d:
			x = i - d[tuple(calc(state))]
			if x < ans:
				ans = x
				res = (d[tuple(calc(state))] + 1, i + 1)
			d[tuple(calc(state))] = i + 1
		else:
			d[tuple(calc(state))] = i + 1
	if ans == 10 ** 18:
		print(-1)
	else:
		print(res[0], res[1])


from math import *
t = int(input())
while t > 0:
	n = int(input())
	s = input()
	x = 0
	y = 0
	a = []
	a.append([x, y, 0])
	for i in range(len(s)):
		if s[i] == 'L':
			x += 1
		elif s[i] == 'R':
			x -= 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		a.append([x, y, i + 1])
	a.sort()
	mini = 1000000000
	flag = 0
	for i in range(1, len(a)):
		if a[i][0] == a[i - 1][0] and a[i][1] == a[i - 1][1]:
			flag = 1
			d = a[i][2] - a[i - 1][2]
			if mini > d:
				mini = d
				x = a[i - 1][2]
				y = a[i][2]
	if flag == 0:
		print(-1)
	else:
		print(x + 1, y)
	t -= 1


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	values = {(0, 0): -1}
	(x, y) = (0, 0)
	subs = []
	for (i, currentDir) in enumerate(s):
		if currentDir == 'U':
			y += 1
		elif currentDir == 'R':
			x += 1
		elif currentDir == 'D':
			y -= 1
		elif currentDir == 'L':
			x -= 1
		temp = (x, y)
		temp2 = values.get(temp, None)
		if temp2 is not None:
			subs.append((values[temp] + 2, i + 1))
		values[temp] = i
	if len(subs) == 0:
		print('-1')
	else:
		subs = sorted(subs, key=lambda x: x[1] - x[0])
		print(subs[0][0], subs[0][1])


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	l = [(0, 0)]
	newSet = set()
	newSet.add((0, 0))
	d = dict()
	d[0, 0] = 0
	m = 10 ** 9
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		pair = (x, y)
		if pair not in d:
			d[pair] = i + 1
			l.append(pair)
			newSet.add(pair)
		else:
			a = d[pair]
			b = i + 1
			if b - a + 1 < m:
				m = b - a + 1
				p = a
				q = b
			d[pair] = i + 1
	if m == 10 ** 9:
		print(-1)
		continue
	p += 1
	print(p, q)


I = input
for _ in [0] * int(I()):
	I()
	a = {1: 1}
	i = s = 1
	r = (-1,)
	m = 300000.0
	for c in I():
		s += ((c == 'R') - (c == 'L') << 16) + (c > 'R') - (c < 'L')
		j = a.get(s, -m)
		if i - j < m:
			m = i - j
			r = (j, i)
		i += 1
		a[s] = i
	print(*r)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = list(input().rstrip())
	visited = {(0, 0): 0}
	coor = (0, 0)
	l = -1
	r = n + 1
	for i in range(n):
		coor = list(coor)
		if s[i] == 'U':
			coor[1] -= 1
		elif s[i] == 'D':
			coor[1] += 1
		elif s[i] == 'L':
			coor[0] -= 1
		elif s[i] == 'R':
			coor[0] += 1
		coor = tuple(coor)
		if coor in visited:
			if i - visited[coor] < r - l:
				l = visited[coor]
				r = i
		visited[coor] = i + 1
	print(-1 if l == -1 else str(l + 1) + ' ' + str(r + 1))


n = int(input())
for i in range(n):
	q = int(input())
	num = 0
	l = -1
	r = -1
	MIN_CONST = 10000000000
	s = str(input())
	coord = [0, 0]
	d = {}
	d[tuple(coord)] = num
	points = set()
	points.add((0, 0))
	for step in s:
		if step == 'U':
			coord[1] += 1
		elif step == 'D':
			coord[1] -= 1
		elif step == 'R':
			coord[0] += 1
		elif step == 'L':
			coord[0] -= 1
		num += 1
		if tuple(coord) not in points:
			points.add(tuple(coord))
			d[tuple(coord)] = num
		else:
			old_num = d[tuple(coord)]
			d[tuple(coord)] = num
			if num - old_num < MIN_CONST:
				l = old_num
				r = num
				MIN_CONST = num - old_num
	if MIN_CONST == 10000000000:
		print(-1)
	else:
		print(l + 1, r)


t = int(input())
for _ in range(t):
	input()
	(x, y) = (0, 0)
	minlen = 10 ** 7
	path = {(0, 0): -1}
	for (pos, step) in enumerate(input()):
		if step == 'U':
			y += 1
		elif step == 'D':
			y -= 1
		elif step == 'L':
			x -= 1
		elif step == 'R':
			x += 1
		if (x, y) in path:
			if minlen > pos - path[x, y]:
				minlen = pos - path[x, y]
				mark = path[x, y] + 2
		path[x, y] = pos
	if minlen < 10 ** 6:
		print(mark, mark + minlen - 1)
	else:
		print(-1)


no = 2 * 1001
for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	d[0, 0] = 0
	(i, j) = (0, 0)
	ans = 100000000
	p = []
	for k in range(1, n + 1):
		a = s[k - 1]
		if a == 'R':
			i += 1
		elif a == 'L':
			i -= 1
		elif a == 'U':
			j -= 1
		elif a == 'D':
			j += 1
		if (i, j) in d:
			if k - d[i, j] < ans:
				ans = k - d[i, j]
				p = [d[i, j] + 1, k]
		d[i, j] = k
	if len(p) == 0:
		print(-1)
		continue
	print(*p)


def main():
	map = {}
	n = int(input())
	s = input()
	curX = 0
	curY = 0
	index = 0
	map[curX, curY] = [index]
	for c in s:
		index += 1
		if c == 'L':
			curX -= 1
		elif c == 'R':
			curX += 1
		elif c == 'U':
			curY += 1
		elif c == 'D':
			curY -= 1
		if (curX, curY) in map:
			map[curX, curY].append(index)
		else:
			map[curX, curY] = [index]
	minDif = 1000000
	a = -1
	b = -1
	for node in map:
		if len(map[node]) > 1:
			prev = None
			for x in map[node]:
				if prev is not None:
					if x - prev < minDif:
						minDif = x - prev
						a = prev
						b = x
				prev = x
	if a >= 0 and b >= 0:
		print(a + 1, ' ', b)
	else:
		print(-1)
t = int(input())
for i in range(t):
	main()


t = int(input())
for i in range(t):
	n = int(input())
	pos = list(input())
	x = 0
	y = 0
	ind = {}
	ind[0, 0] = [0]
	for (index, dir) in enumerate(pos):
		if dir == 'L':
			x -= 1
		elif dir == 'R':
			x += 1
		elif dir == 'U':
			y += 1
		else:
			y -= 1
		pos_tup = (x, y)
		if pos_tup in ind.keys():
			ind[pos_tup].append(index + 1)
		else:
			ind[pos_tup] = [index + 1]
	min_dist = 99999999999
	flag = False
	for k in ind.keys():
		if len(ind[k]) > 1:
			for (j, val) in enumerate(ind[k][:-1]):
				if ind[k][j + 1] - val < min_dist:
					flag = True
					min_dist = ind[k][j + 1] - val
					l = val
					r = ind[k][j + 1]
	if flag:
		print(l + 1, r)
	else:
		print(-1)


import sys

def rl():
	return sys.stdin.readline().strip()

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

def rln(n):
	l = [None] * n
	for i in range(n):
		l[i] = int(rl())
	return l
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	cur = [0, 0]
	vis = dict()
	vis[0, 0] = 0
	(min_r, min_l) = (n + 1, -1)
	for i in range(n):
		if s[i] == 'R':
			cur[0] += 1
		if s[i] == 'L':
			cur[0] -= 1
		if s[i] == 'U':
			cur[1] += 1
		if s[i] == 'D':
			cur[1] -= 1
		if (cur[0], cur[1]) in vis:
			if min_r - min_l > i - vis[cur[0], cur[1]]:
				min_r = i
				min_l = vis[cur[0], cur[1]]
		vis[cur[0], cur[1]] = i + 1
	if min_l != -1:
		print(min_l + 1, min_r + 1)
	else:
		print(-1)


def robotwalk(n, s):
	x = y = 0
	d = {(x, y): 0}
	flag = 0
	mini = 2147483647
	ans = [0, 0]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in d:
			l = d[x, y] + 1
			r = i + 1
			if r - l < mini:
				mini = r - l
				ans = [l, r]
		d[x, y] = i + 1
	if sum(ans) == 0:
		print(-1)
	else:
		print(*ans)
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	robotwalk(n, s)


import math
testCases = int(input())
for test in range(testCases):
	n = int(input())
	path = input()
	dictionary = {(0, 0): -1}
	x = 0
	y = 0
	ans = 10 ** 9
	for index in range(n):
		if path[index] == 'R':
			x += 1
		elif path[index] == 'L':
			x -= 1
		elif path[index] == 'U':
			y += 1
		elif path[index] == 'D':
			y -= 1
		if (x, y) in dictionary and ans > index - dictionary[x, y]:
			ans = index - dictionary[x, y]
			p = dictionary[x, y] + 1
			q = index
		dictionary[x, y] = index
	if ans != 10 ** 9:
		print(p + 1, q + 1)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	position_to_step = {(0, 0): 0}
	len_of_min = n + 1
	ans = (0, 0)
	pos = (0, 0)
	for i in range(n):
		item = s[i]
		if item == 'U':
			pos = (pos[0], pos[1] + 1)
		elif item == 'D':
			pos = (pos[0], pos[1] - 1)
		if item == 'R':
			pos = (pos[0] + 1, pos[1])
		if item == 'L':
			pos = (pos[0] - 1, pos[1])
		if pos in position_to_step:
			if i - position_to_step[pos] < len_of_min:
				len_of_min = i - position_to_step[pos]
				ans = (position_to_step[pos], i)
		position_to_step[pos] = i + 1
	if ans[0] == ans[1]:
		print(-1)
	else:
		print(ans[0] + 1, ans[1] + 1)


I = input
d = {'L': (-1, 0), 'R': (1, 0), 'D': (0, -1), 'U': (0, 1)}
for _ in [0] * int(I()):
	I()
	a = {(1, 1): 1}
	i = s = t = 1
	r = (-1,)
	m = 300000.0
	for c in I():
		(x, y) = d[c]
		s += x
		t += y
		j = a.get((s, t), -m)
		if i - j < m:
			m = i - j
			r = (j, i)
		i += 1
		a[s, t] = i
	print(*r)


for i in range(int(input())):
	q = input()
	locations = {(0, 0): 1}
	x = 0
	y = 0
	first_index = -1
	last_index = 1
	min_sub_len = 200000
	min_sub = []
	path = input()
	for each in path:
		if each == 'L':
			x -= 1
		elif each == 'R':
			x += 1
		elif each == 'U':
			y += 1
		elif each == 'D':
			y -= 1
		if locations.get((x, y)) is None:
			locations[x, y] = last_index + 1
		else:
			first_index = locations.get((x, y))
			if last_index - first_index < min_sub_len:
				min_sub_len = last_index - first_index
				min_sub = [first_index, last_index]
			locations[x, y] = last_index + 1
		if last_index - first_index == 1:
			break
		last_index += 1
	if not min_sub:
		print('-1')
	else:
		print(min_sub[0], min_sub[1])


T = int(input())
for cs in range(T):
	n = int(input())
	s = input()
	li = [(0, 0, -1)]
	(x, y, i) = (0, 0, 0)
	for c in s:
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		else:
			y -= 1
		li.append((x, y, i))
		i += 1
	li.sort()
	prev = li[0]
	(l, r, mn) = (-1, -1, 1000000)
	for t in li[1:]:
		if t[0] != prev[0] or t[1] != prev[1]:
			prev = t
			continue
		diff = t[2] - prev[2]
		if diff < mn:
			(l, r, mn) = (prev[2] + 1, t[2], diff)
		prev = t
	if l == -1:
		print(-1)
	else:
		print('{} {}'.format(l + 1, r + 1))


def optimize(path):
	time = 0
	visits = {(0, 0): 0}
	position = (0, 0)
	current_min = float('inf')
	best_subpath = (-1, -1)
	for direction in path:
		position = move(direction, position)
		time += 1
		if position not in visits:
			visits[position] = time
			continue
		subpath_length = time - visits[position]
		if subpath_length < current_min:
			current_min = subpath_length
			best_subpath = (visits[position], time)
		visits[position] = time
	(best_left, best_right) = best_subpath
	return (best_left + 1, best_right)

def move(direction, position):
	(x, y) = position
	possible_moves = {'L': (x - 1, y), 'R': (x + 1, y), 'U': (x, y + 1), 'D': (x, y - 1)}
	return possible_moves[direction]
number_of_tests = int(input())
for _ in range(number_of_tests):
	input()
	path = input()
	(left, right) = optimize(path)
	if right == -1:
		print(-1)
		continue
	print(left, right)


t = int(input())
ans = []
for i in range(t):
	ans.append([0, 10 ** 10])
for kek in range(t):
	n = int(input())
	s = list(input())
	c = dict()
	now = [0, 0]
	j = 0
	c[tuple(now)] = list()
	c[tuple(now)].append(j)
	for i in s:
		if i == 'U':
			now = [now[0], now[1] + 1]
		if i == 'D':
			now = [now[0], now[1] - 1]
		if i == 'R':
			now = [now[0] + 1, now[1]]
		if i == 'L':
			now = [now[0] - 1, now[1]]
		j += 1
		if tuple(now) in c:
			c[tuple(now)].append(j)
		else:
			c[tuple(now)] = list()
			c[tuple(now)].append(j)
	for i in c.values():
		if len(i) == 0:
			continue
		else:
			for j in range(len(i) - 1):
				if ans[kek][1] - ans[kek][0] > i[j + 1] - i[j]:
					ans[kek][1] = i[j + 1]
					ans[kek][0] = i[j]
for i in range(t):
	ans[i] = [ans[i][0] + 1, ans[i][1]]
	if ans[i][1] >= 10 ** 9:
		print(-1)
	else:
		print(*ans[i])


import sys, math
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__

def getInts():
	return [int(s) for s in input().split()]

def getInt():
	return int(input())

def getStrs():
	return [s for s in input().split()]

def getStr():
	return input()

def listStr():
	return list(input())
import collections as col
import math

def solve():
	N = getInt()
	S = listStr()
	pos = col.defaultdict(list)
	curr_pos = [0, 0]
	pos[tuple(curr_pos)].append(-1)
	for n in range(N):
		if S[n] == 'L':
			curr_pos[0] -= 1
		elif S[n] == 'R':
			curr_pos[0] += 1
		elif S[n] == 'D':
			curr_pos[1] -= 1
		else:
			curr_pos[1] += 1
		pos[tuple(curr_pos)].append(n)
	found = False
	best = 10 ** 9
	for p in pos:
		if len(pos[p]) < 2:
			continue
		found = True
		for i in range(len(pos[p]) - 1):
			diff = pos[p][i + 1] - pos[p][i]
			if diff < best:
				best = diff
				best_pos = [pos[p][i] + 2, pos[p][i + 1] + 1]
	if found:
		print(*best_pos)
		return
	else:
		print(-1)
		return
for t in range(getInt()):
	solve()


for _ in range(int(input())):
	n = int(input())
	string = input()
	dic = {}
	initial = [0, 0]
	dic[tuple(initial)] = -1
	min1 = float('Inf')
	output = -1
	for i in range(n):
		if string[i] == 'L':
			initial[0] -= 1
		elif string[i] == 'R':
			initial[0] += 1
		elif string[i] == 'U':
			initial[1] += 1
		elif string[i] == 'D':
			initial[1] -= 1
		if tuple(initial) in dic:
			min1 = min(min1, i - dic[tuple(initial)])
			if min1 == i - dic[tuple(initial)]:
				output = [dic[tuple(initial)] + 1, i]
		dic[tuple(initial)] = i
	if output == -1:
		print(output)
		continue
	output[0] += 1
	output[1] += 1
	print(output[0], end=' ')
	print(output[1])


def check(arr):
	pass

def solve(n, d):
	back_pair = {}
	back_pair[0, 0] = 0
	point = [0, 0]
	ranger = n
	lb = -1
	rb = n + 1
	for r in range(n):
		i = d[r]
		if i == 'L':
			point[0] -= 1
		elif i == 'R':
			point[0] += 1
		elif i == 'U':
			point[1] += 1
		else:
			point[1] -= 1
		tup_point = tuple(point)
		if tup_point in back_pair:
			plb = back_pair[tup_point]
			new_range = r - plb + 1
			ranger = rb - lb
			if new_range < ranger:
				lb = plb + 1
				rb = r + 1
		back_pair[tup_point] = r + 1
	if lb == -1:
		print(-1)
	else:
		print(lb, rb)

def main():
	t = int(input())
	for i in range(t):
		n = int(input())
		d = input()
		ans = solve(n, d)
main()
n = 3
d = 'URL'


import sys
input = sys.stdin.readline
for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {(0, 0): -1}
	(x, y, ans) = (0, 0, 10 ** 6)
	final_ans = -1
	for i in range(len(s) - 1):
		k = s[i]
		if k == 'L':
			x -= 1
		elif k == 'R':
			x += 1
		elif k == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			if ans > i - d[x, y]:
				final_ans = (d[x, y] + 1, i)
				ans = i - d[x, y]
		d[x, y] = i
	if final_ans == -1:
		print(final_ans)
	else:
		print(final_ans[0] + 1, final_ans[1] + 1)


t = int(input())
for j in range(t):
	n = int(input())
	path = input()
	left = [0] * n
	right = [0] * n
	up = [0] * n
	down = [0] * n
	left_right_flag = [0] * n
	up_down_flag = [0] * n
	new = [[0, 0, 0]] * (n + 1)
	for i in range(n):
		left[i] = left[i - 1]
		right[i] = right[i - 1]
		up[i] = up[i - 1]
		down[i] = down[i - 1]
		if path[i] == 'L':
			left[i] = left[i] + 1
		elif path[i] == 'R':
			right[i] = right[i] + 1
		elif path[i] == 'U':
			up[i] = up[i] + 1
		else:
			down[i] = down[i] + 1
		new[i + 1] = [left[i] - right[i], up[i] - down[i], i + 1]
	new.sort(key=lambda x: (x[0], x[1], x[2]), reverse=True)
	value = n + 1
	for i in range(1, n + 1):
		if new[i][0] == new[i - 1][0] and new[i][1] == new[i - 1][1]:
			value = min(value, new[i - 1][2] - new[i][2])
	success = 0
	start = -1
	stop = -1
	for i in range(1, n + 1):
		if new[i][0] == new[i - 1][0] and new[i][1] == new[i - 1][1] and (new[i - 1][2] - new[i][2] == value):
			success = 1
			stop = new[i - 1][2]
			start = new[i][2] + 1
			break
	if success == 1:
		print(start, stop)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	d = {(0, 0): -1}
	x = 0
	y = 0
	ans = 1000000000
	xi = 0
	yi = 1
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		a = (x, y)
		if a in d:
			if i - d[a] < ans:
				ans = i - d[a]
				if d[a] == -1:
					xi += 1
				xi = d[a] + 2
				yi = i + 1
				d[a] = i
			d[a] = i
		else:
			d[a] = i
	if ans == 1000000000:
		print('-1')
	else:
		print(str(xi) + ' ' + str(yi))


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

def move(mv, x, y):
	if mv == 'L':
		return (x - 1, y)
	elif mv == 'R':
		return (x + 1, y)
	elif mv == 'U':
		return (x, y + 1)
	else:
		return (x, y - 1)
for _ in range(t):
	n = int(input())
	path = list(input())
	visited = defaultdict(list)
	visited[0, 0].append(0)
	curr = (0, 0)
	for i in range(0, n):
		curr = move(path[i], *curr)
		visited[curr].append(i + 1)
	mn = float('inf')
	ans = None
	for key in visited.keys():
		arr = visited[key]
		for i in range(0, len(arr) - 1):
			if mn > arr[i + 1] - arr[i]:
				ans = (arr[i] + 1, arr[i + 1])
				mn = arr[i + 1] - arr[i]
	if mn == float('inf'):
		print(-1)
	else:
		print(f'{ans[0]} {ans[1]}')


q = int(input())
for i in range(q):
	n = int(input())
	l = list(input())
	a = []
	for i in range(n + 1):
		a.append([0, 0, i])
	x = 0
	y = 0
	for i in range(n):
		if l[i] == 'L':
			x -= 1
		elif l[i] == 'R':
			x += 1
		elif l[i] == 'U':
			y += 1
		else:
			y -= 1
		a[i + 1][0] = x
		a[i + 1][1] = y
	a.sort()
	x = 1
	y = n
	flag = 0
	for i in range(n):
		if a[i][0] == a[i + 1][0] and a[i][1] == a[i + 1][1]:
			if a[i + 1][2] - a[i][2] <= y - x + 1:
				x = a[i][2] + 1
				y = a[i + 1][2]
				flag = 1
	if flag == 0:
		print(-1)
	else:
		print(x, y)


from sys import stdin, stdout
from collections import deque
st = lambda : list(stdin.readline().strip())
li = lambda : list(map(int, stdin.readline().split()))
mp = lambda : map(int, stdin.readline().split())
inp = lambda : int(stdin.readline())
pr = lambda n: stdout.write(str(n) + '\n')
mod = 1000000007
INF = float('inf')

def solve():
	MIN = INF
	d = {(0, 0): 0}
	n = inp()
	s = ['Z'] + st()
	(x, y) = (0, 0)
	(X_cor, Y_cor) = (-1, -1)
	for i in range(1, n + 1):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'D':
			y -= 1
		if s[i] == 'U':
			y += 1
		if (x, y) in d:
			A = d[x, y]
			if i - A < MIN:
				X_cor = A + 1
				Y_cor = i
				MIN = i - A
				d[x, y] = i
			else:
				d[x, y] = i
		else:
			d[x, y] = i
	if MIN != INF:
		print(X_cor, Y_cor)
	else:
		print(-1)
for _ in range(inp()):
	solve()


t = int(input())
for _ in range(t):
	n = int(input())
	arr = input()
	(i, j) = (0, 0)
	dic = {(0, 0): 0}
	(mn, ans) = (float('inf'), -1)
	for ind in range(n):
		if arr[ind] == 'L':
			j += 1
		if arr[ind] == 'R':
			j -= 1
		if arr[ind] == 'U':
			i += 1
		if arr[ind] == 'D':
			i -= 1
		if (i, j) in dic and ind - dic[i, j] < mn:
			mn = ind - dic[i, j]
			ans = (dic[i, j] + 1, ind + 1)
		dic[i, j] = ind + 1
	if ans == -1:
		print(-1)
	else:
		print(str(ans[0]), str(ans[1]))


def update_loc(x, y, to):
	if to == 'R':
		x = x + 1
	elif to == 'L':
		x = x - 1
	elif to == 'D':
		y = y - 1
	elif to == 'U':
		y = y + 1
	return (x, y)
t = int(input())
for _ in range(t):
	input()
	s = input()
	(x, y) = (0, 0)
	g = {(x, y): 0}
	(l, r) = (0, 1000000)
	for (i, direction) in enumerate(s):
		i = i + 1
		(x, y) = update_loc(x, y, direction)
		if (x, y) in g.keys():
			v = g[x, y]
			if i - v < r - l:
				(l, r) = (v + 1, i)
		g[x, y] = i
	if r == 1000000:
		print(-1)
	else:
		print(l, r)


import sys

def query():
	n = int(input())
	s = input()
	point = {}
	point[0, 0] = -1
	cur = [0, 0]
	min = 1000000000.0
	l = r = -2
	for (i, x) in enumerate(s):
		if x == 'L':
			cur[0] -= 1
		if x == 'R':
			cur[0] += 1
		if x == 'U':
			cur[1] += 1
		if x == 'D':
			cur[1] -= 1
		now = tuple(cur)
		if now in point:
			if i - point[now] < min:
				min = i - point[now]
				l = point[now]
				r = i
		point[now] = i
	if l == -2:
		print(-1)
	else:
		print(l + 2, r + 1)
q = int(input())
for i in range(0, q):
	query()


from sys import stdin, stdout
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = input()
	d = {(0, 0): -1}
	smx = smy = 0
	mn = n + 1
	for i in range(n):
		if s[i] == 'L':
			smx += 1
		elif s[i] == 'R':
			smx -= 1
		elif s[i] == 'U':
			smy += 1
		elif s[i] == 'D':
			smy -= 1
		if (smx, smy) in d:
			len_seg = i - d[smx, smy]
			if len_seg < mn:
				mn = len_seg
				ll = d[smx, smy] + 1
				rr = i
		d[smx, smy] = i
	if mn == n + 1:
		print(-1)
	else:
		print(ll + 1, rr + 1)


from math import inf
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	p = [(0, 0)]
	for x in s:
		(lx, ly) = p[-1]
		if x == 'L':
			p.append((lx - 1, ly))
		if x == 'R':
			p.append((lx + 1, ly))
		if x == 'U':
			p.append((lx, ly + 1))
		if x == 'D':
			p.append((lx, ly - 1))
	seen = {(0, 0): 0}
	ans = inf
	ansi = -1
	ansj = -1
	for i in range(1, len(p)):
		if p[i] in seen:
			if ans > i - seen[p[i]]:
				ans = i - seen[p[i]]
				ansi = seen[p[i]]
				ansj = i
		seen[p[i]] = i
	print(ansi + 1, ansj) if ans < inf else print(-1)


big = 10 ** 6

def solution(n, path):
	points = [(0, 0, 0)]
	for i in range(n):
		pi = points[i]
		if path[i] == 'L':
			points.append((pi[0] - 1, pi[1], i + 1))
		if path[i] == 'R':
			points.append((pi[0] + 1, pi[1], i + 1))
		if path[i] == 'U':
			points.append((pi[0], pi[1] + 1, i + 1))
		if path[i] == 'D':
			points.append((pi[0], pi[1] - 1, i + 1))
	points.sort()
	mi = big
	mindex = (-1,)
	for i in range(n):
		if points[i][:2] == points[i + 1][:2] and points[i + 1][2] - points[i][2] < mi:
			mi = points[i + 1][2] - points[i][2]
			mindex = (points[i][2] + 1, points[i + 1][2])
	print(' '.join(map(str, mindex)))
t = int(input())
for i in range(t):
	n = int(input())
	path = input()
	solution(n, path)


move = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}

def best_move(s, n):
	best = [-1]
	pos = {(0, 0): 0}
	current = (0, 0)
	for i in range(n):
		current = tuple([current[j] + move[s[i]][j] for j in range(2)])
		if current in pos and (best == [-1] or i - pos[current] < best[1] - best[0]):
			best = [pos[current] + 1, i + 1]
		pos[current] = i + 1
	return best
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	m = best_move(s, n)
	for i in m:
		print(i, end=' ')
	print('')


def run():
	mydic = {}
	path = [0, 0]
	n = int(input())
	mystr = input()
	ans = []
	for (index, i) in enumerate(mystr, 1):
		mydic[path[0], path[1]] = index
		if i == 'R':
			path[0] += 1
		elif i == 'L':
			path[0] -= 1
		elif i == 'U':
			path[1] += 1
		else:
			path[1] -= 1
		if (path[0], path[1]) in mydic:
			ans.append([mydic[path[0], path[1]], index])
		mydic[path[0], path[1]] = index
	if not ans:
		print(-1)
		return
	ans.sort(key=lambda x: x[1] - x[0])
	print(ans[0][0], ans[0][1])
t = int(input())
for i in range(t):
	run()


tc = int(input())
for t in range(tc):
	n = int(input())
	s = input()
	d = {}
	lr = 0
	up = 0
	d['0 0'] = -1
	res = len(s) + 1
	rstr = '-1'
	for ind in range(len(s)):
		i = s[ind]
		if i == 'L':
			lr = lr - 1
		elif i == 'R':
			lr = lr + 1
		elif i == 'U':
			up = up + 1
		else:
			up = up - 1
		ss = str(lr) + ' ' + str(up)
		if ss in d:
			if ind + 1 - (d[ss] + 2) < res:
				rstr = str(d[ss] + 2) + ' ' + str(ind + 1)
				res = ind + 1 - (d[ss] + 2)
		d[ss] = ind
	print(rstr)


for l in range(int(input(''))):
	n = int(input(''))
	s = input('')
	ans = (0, 10 ** 10)
	d = {(0, 0): 0}
	x = (0, 0)
	for m in range(n):
		if s[m] == 'L':
			x = (x[0] - 1, x[1])
		elif s[m] == 'R':
			x = (x[0] + 1, x[1])
		elif s[m] == 'U':
			x = (x[0], x[1] + 1)
		else:
			x = (x[0], x[1] - 1)
		if x in d:
			if m + 1 - d[x] < ans[1] - ans[0]:
				ans = (d[x] + 1, m + 1)
			d[x] = m + 1
		else:
			d[x] = m + 1
	if ans[1] == 10 ** 10:
		print(-1)
	else:
		print(str(ans[0]) + ' ' + str(ans[1]))


import sys
input = sys.stdin.readline
scan_int = lambda : int(input())
scan_string = lambda : input().rstrip()
read_list = lambda : list(read())
read = lambda : map(int, input().split())
read_float = lambda : map(float, input().split())

def ceil(x):
	if x != int(x):
		x = int(x) + 1
	return x

def factorial(x, m):
	val = 1
	while x > 0:
		val = val * x % m
		x -= 1
	return val

def fact(x):
	val = 1
	while x > 0:
		val *= x
		x -= 1
	return val

def swaparr(arr, a, b):
	temp = arr[a]
	arr[a] = arr[b]
	arr[b] = temp

def gcd(a, b):
	if b == 0:
		return a
	return gcd(b, a % b)

def lcm(a, b):
	return a * b // math.gcd(a, b)

def nCr(n, k):
	if k > n:
		return 0
	if k > n - k:
		k = n - k
	res = 1
	for i in range(k):
		res = res * (n - i)
		res = res / (i + 1)
	return int(res)

def primefs(n):
	primes = {}
	while n % 2 == 0 and n > 0:
		primes[2] = primes.get(2, 0) + 1
		n = n // 2
	for i in range(3, int(n ** 0.5) + 2, 2):
		while n % i == 0 and n > 0:
			primes[i] = primes.get(i, 0) + 1
			n = n // i
	if n > 2:
		primes[n] = primes.get(n, 0) + 1
	return primes

def power(x, y, p):
	res = 1
	x = x % p
	if x == 0:
		return 0
	while y > 0:
		if y & 1 == 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def swap(a, b):
	temp = a
	a = b
	b = temp
	return (a, b)

def find(x, link):
	p = x
	while p != link[p]:
		p = link[p]
	while x != p:
		nex = link[x]
		link[x] = p
		x = nex
	return p

def union(x, y, link, size):
	x = find(x, link)
	y = find(y, link)
	if size[x] < size[y]:
		(x, y) = swap(x, y)
	if x != y:
		size[x] += size[y]
		link[y] = x

def sieve(n):
	prime = [True for i in range(n + 1)]
	(prime[0], prime[1]) = (False, False)
	p = 2
	while p * p <= n:
		if prime[p] == True:
			for i in range(p * p, n + 1, p):
				prime[i] = False
		p += 1
	return prime

def phi(n):
	result = n
	p = 2
	while p * p <= n:
		if n % p == 0:
			while n % p == 0:
				n = n // p
			result = result * (1.0 - 1.0 / float(p))
		p = p + 1
	if n > 1:
		result = result * (1.0 - 1.0 / float(n))
	return int(result)

def is_prime(n):
	if n == 0:
		return False
	if n == 1:
		return True
	for i in range(2, int(n ** (1 / 2)) + 1):
		if not n % i:
			return False
	return True

def next_prime(n, primes):
	while primes[n] != True:
		n += 1
	return n
MAXN = int(100000.0 + 5)

def spf_sieve():
	spf[1] = 1
	for i in range(2, MAXN):
		spf[i] = i
	for i in range(4, MAXN, 2):
		spf[i] = 2
	for i in range(3, ceil(MAXN ** 0.5), 2):
		if spf[i] == i:
			for j in range(i * i, MAXN, i):
				if spf[j] == j:
					spf[j] = i
spf = [0 for i in range(MAXN)]

def factoriazation(x):
	res = []
	for i in range(2, int(x ** 0.5) + 1):
		while x % i == 0:
			res.append(i)
			x //= i
	if x != 1:
		res.append(x)
	return res

def factors(n):
	res = []
	for i in range(1, int(n ** 0.5) + 1):
		if n % i == 0:
			res.append(i)
			res.append(n // i)
	return list(set(res))

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

def float_array():
	return list(map(float, input().strip().split()))

def str_array():
	return input().strip().split()

def binary_search(low, high, w, h, n):
	while low < high:
		mid = low + (high - low) // 2
		if check(mid, w, h, n):
			low = mid + 1
		else:
			high = mid
	return low

def check(beauty, s, n, count):
	pass
MOD = int(1000000000.0) + 7
CMOD = 998244353
INF = float('inf')
NINF = -float('inf')
from itertools import permutations
import math
import bisect as bis
import random
import sys

def solve():
	n = scan_int()
	robot = scan_string()
	x = 0
	y = 0
	ind = n + 1
	ans = []
	ans.append([x, y, ind])
	for i in range(n - 1, -1, -1):
		ind = i + 1
		if robot[i] == 'U':
			y += 1
		elif robot[i] == 'D':
			y -= 1
		elif robot[i] == 'R':
			x += 1
		elif robot[i] == 'L':
			x -= 1
		ans.append([x, y, ind])
	ans.sort()
	r = INF
	l = 0
	for i in range(1, len(ans)):
		if ans[i][0] == ans[i - 1][0] and ans[i][1] == ans[i - 1][1]:
			o = ans[i][2] - 1
			k = ans[i - 1][2]
			if o - k + 1 <= r - l + 1:
				(r, l) = (o, k)
	if r == INF:
		print(-1)
	else:
		print(l, r)
for _ in range(int(input())):
	solve()


import math
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	d = dict()
	(x, y) = (0, 0)
	d[x, y] = 0
	(l, r) = (-1, n)
	for i in range(n):
		c = s[i]
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		if (x, y) in d and i - d[x, y] < r - l:
			l = d[x, y]
			r = i
		d[x, y] = i + 1
	if l != -1:
		print(l + 1, r + 1)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	s = input()
	k = (0, 0)
	d = {}
	d[k] = -1
	s1 = (0, 0)
	min1 = 1000000000000000
	for i in range(n):
		if s[i] == 'L':
			k = (k[0] - 1, k[1])
		elif s[i] == 'R':
			k = (k[0] + 1, k[1])
		elif s[i] == 'D':
			k = (k[0], k[1] - 1)
		else:
			k = (k[0], k[1] + 1)
		if d.get(k) != None:
			if i - d[k] < min1:
				min1 = i - d[k]
				s1 = (d[k] + 1, i)
		d[k] = i
	if min1 == 1000000000000000:
		print(-1)
	else:
		print(s1[0] + 1, s1[1] + 1)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	s = str(input())
	d = defaultdict(list)
	x = 0
	y = 0
	m = 1000000000
	j = 0
	d[0, 0].append(1)
	for i in range(n):
		if s[i] == 'L':
			x = x - 1
		elif s[i] == 'R':
			x = x + 1
		elif s[i] == 'U':
			y = y + 1
		elif s[i] == 'D':
			y = y - 1
		if len(d[x, y]) == 0:
			d[x, y].append(i + 2)
		else:
			j = 1
			if i + 2 - d[x, y][-1] < m:
				m = i + 2 - d[x, y][-1]
				p1 = d[x, y][-1]
				p2 = i + 1
			d[x, y].append(i + 2)
	if j == 0:
		print(-1)
	else:
		print(p1, p2)


import math
t = int(input())
for _ in range(t):
	n = int(input())
	mov = input()
	dc = {}
	last = (0, 0)
	dc[last] = 1
	bst = 2 * n
	bstx = -1
	bsty = -1
	for i in range(len(mov)):
		if mov[i] == 'U':
			(x, y) = last
			last = (x + 1, y)
		elif mov[i] == 'D':
			(x, y) = last
			last = (x - 1, y)
		elif mov[i] == 'R':
			(x, y) = last
			last = (x, y + 1)
		elif mov[i] == 'L':
			(x, y) = last
			last = (x, y - 1)
		if last in dc.keys():
			now = i - dc[last] + 2
			if now < bst:
				bst = now
				bstx = dc[last]
				bsty = i + 1
		dc[last] = i + 2
	if bstx == -1:
		print(-1)
	else:
		print(bstx, bsty)


import sys
testcases = int(input())
for k in range(testcases):
	n = int(input())
	rstrings = list(sys.stdin.readline())
	coords = {}
	coords[0, 0] = 1
	indices = {}
	x = 0
	y = 0
	cv = 0
	smallestsofar = n + 1
	smallestslice = [0]
	exists = False
	while cv <= n - 1:
		if not (x, y) in indices:
			indices[x, y] = []
			indices[x, y].append(cv)
		else:
			indices[x, y].append(cv)
		if rstrings[cv] == 'R':
			x += 1
		elif rstrings[cv] == 'L':
			x += -1
		elif rstrings[cv] == 'U':
			y += 1
		elif rstrings[cv] == 'D':
			y += -1
		if not (x, y) in coords:
			coords[x, y] = 1
		elif (x, y) in coords:
			coords[x, y] += 1
		if coords[x, y] >= 2:
			exists = True
			i = indices[x, y][-1]
			if cv - i < smallestsofar:
				smallestsofar = cv - i
				smallestslice[0] = (i, cv)
		cv += 1
	if exists == True:
		sys.stdout.write('\n' + str(smallestslice[0][0] + 1) + ' ' + str(smallestslice[0][1] + 1))
	else:
		sys.stdout.write('\n' + str(-1))


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	visited = {(0, 0): 0}
	x = 0
	y = 0
	l = -1
	r = n
	for (i, m) in enumerate(s):
		if m == 'R':
			x += 1
		elif m == 'L':
			x -= 1
		elif m == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in visited and i - visited[x, y] + 1 < r - l + 1:
			l = visited[x, y]
			r = i
		visited[x, y] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


ways = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
t = int(input())
result = []
for _ in range(t):
	n = int(input())
	s = list(input())
	pos = [0, 0]
	positions = {'0,0': 0}
	minimum = n + 1
	min_lr = [-1]
	for (i, turn) in enumerate(s):
		(dx, dy) = ways[turn]
		pos[0] += dx
		pos[1] += dy
		string = ','.join([str(pos[0]), str(pos[1])])
		if string in positions:
			if i - positions[string] < minimum:
				minimum = i - positions[string]
				min_lr = [positions[string] + 1, i + 1]
		positions[string] = i + 1
	result.append(min_lr)
for i in result:
	print(*i)


import sys

def optim(s):
	dots = dict()
	(x, y) = (0, 0)
	dots[x, y] = 0
	paths = []
	for (m, i) in enumerate(s):
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'D':
			y -= 1
		elif i == 'U':
			y += 1
		else:
			continue
		if (x, y) in dots:
			paths.append((dots[x, y] + 1, m + 1))
		dots[x, y] = m + 1
	if paths:
		return sorted(paths, key=lambda x: x[1] - x[0])[0]
	return [-1]
n = int(sys.stdin.readline())
for i in range(n):
	a = int(sys.stdin.readline())
	s = sys.stdin.readline()
	print(' '.join((str(s) for s in optim(s))))


from collections import defaultdict
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	ans = [-1, n]
	d = defaultdict(list)
	d[0, 0] = 0
	cur = [0, 0]
	for i in range(n):
		if s[i] == 'U':
			cur[1] += 1
		elif s[i] == 'D':
			cur[1] -= 1
		elif s[i] == 'R':
			cur[0] += 1
		else:
			cur[0] -= 1
		yep = (cur[0], cur[1])
		if yep in d.keys():
			if ans[1] - ans[0] > i + 1 - (d[yep] + 1):
				ans = [d[yep] + 1, i + 1]
		d[yep] = i + 1
	if ans[0] == -1 and ans[1] == n:
		print(-1)
	else:
		print(ans[0], ans[1])


from math import factorial
from collections import defaultdict
from heapq import heapify, heappop, heappush
from sys import stdin

def RL():
	return map(int, stdin.readline().rstrip().split())

def comb(n, m):
	return factorial(n) / (factorial(m) * factorial(n - m)) if n >= m else 0

def perm(n, m):
	return factorial(n) // factorial(n - m) if n >= m else 0

def mdis(x1, y1, x2, y2):
	return abs(x1 - x2) + abs(y1 - y2)
mod = 1000000007
N = int(input())
for _ in range(N):
	n = int(input())
	s = input()
	dic = {}
	pos = (0, 0)
	dic[pos] = 0
	res = (0, float('inf'))
	for (i, v) in enumerate(s):
		id = i + 1
		if v == 'L':
			pos = (pos[0] - 1, pos[1])
		elif v == 'R':
			pos = (pos[0] + 1, pos[1])
		elif v == 'U':
			pos = (pos[0], pos[1] + 1)
		elif v == 'D':
			pos = (pos[0], pos[1] - 1)
		if (pos[0], pos[1]) in dic:
			if id - dic[pos] < res[1] - res[0]:
				res = (dic[pos] + 1, id)
		dic[pos[0], pos[1]] = id
	if res == (0, float('inf')):
		print(-1)
	else:
		print(res[0], res[1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	pos = {(0, 0): -1}
	x = y = 0
	L = -1
	R = float('inf')
	flag = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in pos:
			curR = i
			curL = pos[x, y]
			if curR - curL < R - L:
				(R, L) = (curR, curL)
				flag = 1
		pos[x, y] = i
	if flag == 1:
		print(L + 2, R + 1)
	else:
		print('-1')


import sys
import collections
input = sys.stdin.readline

def main():
	t = int(input())
	for _ in range(t):
		N = int(input())
		S = input().strip()
		x = 0
		y = 0
		c = collections.Counter()
		d = {}
		d['0,0'] = 0
		c['0,0'] += 1
		ans = []
		for (i, s) in enumerate(S):
			if s == 'R':
				x += 1
			elif s == 'L':
				x -= 1
			elif s == 'U':
				y += 1
			elif s == 'D':
				y -= 1
			if c[str(x) + ',' + str(y)] != 0:
				ans.append([i + 1 - d[str(x) + ',' + str(y)], d[str(x) + ',' + str(y)] + 1, i + 1])
				c[str(x) + ',' + str(y)] += 1
				d[str(x) + ',' + str(y)] = i + 1
			else:
				c[str(x) + ',' + str(y)] += 1
				d[str(x) + ',' + str(y)] = i + 1
		ans.sort()
		if len(ans) == 0:
			print(-1)
		else:
			print(ans[0][1], ans[0][2])
main()


import sys
f_in = sys.stdin
f_out = sys.stdout
case_number = int(f_in.readline())
for i in range(0, case_number):
	step = int(f_in.readline())
	step_direction = f_in.readline()
	x = 0
	y = 0
	dic = {(0, 0): [-1, 0, 0]}
	pre = 0
	last = 0
	for j in range(0, step):
		if step_direction[j] == 'L':
			x = x - 1
		elif step_direction[j] == 'R':
			x = x + 1
		elif step_direction[j] == 'U':
			y = y + 1
		elif step_direction[j] == 'D':
			y = y - 1
		if not (x, y) in dic:
			dic[x, y] = [j, 0, 0]
		elif dic[x, y][1] == 0:
			dic[x, y][1] = j
		elif j - dic[x, y][2] < dic[x, y][1] - dic[x, y][0]:
			dic[x, y][0] = dic[x, y][2]
			dic[x, y][1] = j
		dic[x, y][2] = j
	for (key, value) in dic.items():
		if value[1] == 0:
			continue
		elif pre == 0 or value[1] - value[0] < last - pre:
			pre = value[0] + 2
			last = value[1] + 1
	if pre == 0:
		f_out.write('-1\n')
	else:
		f_out.write(str(pre) + ' ' + str(last) + '\n')
f_in.close()
f_out.close()


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

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

def iinp():
	return int(input())

def test():
	return int(input())

def inp():
	return input()

def solve():
	n = int(input())
	s = input()
	v = {(0, 0): 0}
	curr = (0, 0)
	ans = 1000000000
	(a, b) = (-1, -1)
	for i in range(n):
		if s[i] == 'L':
			curr = (curr[0] - 1, curr[1])
		elif s[i] == 'R':
			curr = (curr[0] + 1, curr[1])
		elif s[i] == 'U':
			curr = (curr[0], curr[1] + 1)
		else:
			curr = (curr[0], curr[1] - 1)
		if curr in v:
			d = i + 1 - v[curr]
			if d < ans:
				ans = d
				a = v[curr] + 1
				b = i + 1
			v[curr] = i + 1
		else:
			v[curr] = i + 1
	if ans == 1000000000:
		print(-1)
	else:
		print(a, b)

def main():
	for _ in range(test()):
		solve()
main()


import sys
for _ in range(int(input())):
	m = 3000000
	n = int(input())
	s = input()
	Map = {0: -1}
	ans = 0
	f = 0
	minans = sys.maxsize
	prev = -1
	curr = -1
	for i in range(len(s)):
		if s[i] == 'L':
			ans += 1
		elif s[i] == 'R':
			ans -= 1
		elif s[i] == 'U':
			ans += m
		elif s[i] == 'D':
			ans -= m
		if ans not in Map:
			Map[ans] = i
		else:
			if i - Map[ans] < minans:
				minans = i - Map[ans]
				prev = Map[ans] + 2
				curr = i + 1
			Map[ans] = i
	if minans == sys.maxsize:
		print('-1')
	else:
		print(prev, curr)


from collections import Counter, defaultdict, deque
import heapq as hq
from itertools import count, islice
import math
import sys
input = sys.stdin.readline
tt = int(input())
for test in range(tt):
	n = int(input())
	seq = input().strip()
	cur = (0, 0)
	seen = {cur: 0}
	best = (10 ** 9, 0, 0)
	for i in range(n):
		c = seq[i]
		if c == 'R':
			cur = (cur[0] + 1, cur[1])
		elif c == 'L':
			cur = (cur[0] - 1, cur[1])
		elif c == 'U':
			cur = (cur[0], cur[1] + 1)
		else:
			cur = (cur[0], cur[1] - 1)
		if cur in seen:
			if best[0] > i - seen[cur]:
				best = (i - seen[cur], seen[cur] + 1, i + 1)
		seen[cur] = i + 1
	if best[0] != 10 ** 9:
		print(best[1], best[2])
	else:
		print(-1)


def get(i, curr):
	if i == 'L':
		(x, y) = (curr[0] - 1, curr[1])
	elif i == 'R':
		(x, y) = (curr[0] + 1, curr[1])
	elif i == 'U':
		(x, y) = (curr[0], curr[1] + 1)
	else:
		(x, y) = (curr[0], curr[1] - 1)
	return (x, y)
for _ in range(int(input())):
	n = int(input())
	l = 's' + input()
	vstd = {(0, 0): 0}
	mini = 10000000
	index = (1, n + 1)
	curr = (0, 0)
	for i in range(1, n + 1):
		curr = get(l[i], curr)
		if curr in vstd:
			d = i - vstd[curr] - 1
			if mini > d:
				mini = d
				index = (vstd[curr] + 1, i)
		vstd[curr] = i
	if mini == 10000000:
		print(-1)
	else:
		print(*index)


from math import ceil
from math import factorial
from collections import *
from operator import itemgetter
ii = lambda : int(input())
iia = lambda : list(map(int, input().split()))
isa = lambda : list(input().split())
t = ii()
for i in range(t):
	n = ii()
	s = input()
	l = [0] * n
	r = [0] * n
	u = [0] * n
	d = [0] * n
	x = 0
	y = 0
	resx = 0
	resy = 0
	flag = 0
	d = defaultdict(lambda : [])
	mini = 10 ** 10
	d[0, 0] = [1]
	for i in range(0, n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		d[x, y].append(i + 2)
		if len(d[x, y]) >= 2 and d[x, y][-1] - d[x, y][-2] < mini:
			flag = 1
			mini = d[x, y][-1] - d[x, y][-2]
			resx = d[x, y][-2]
			resy = d[x, y][-1]
	if flag == 1:
		print(resx, resy - 1)
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	letters = list(input())
	position = (0, 0)
	counter = 1
	visited = {(0, 0): 0}
	minimum = 0
	pos = 0
	flag = False
	for i in letters:
		if i == 'L':
			position = (position[0] - 1, position[1])
		elif i == 'R':
			position = (position[0] + 1, position[1])
		elif i == 'U':
			position = (position[0], position[1] + 1)
		elif i == 'D':
			position = (position[0], position[1] - 1)
		if position in visited:
			if flag:
				if counter - visited[position] < minimum:
					minimum = counter - visited[position]
					pos = visited[position]
					visited[position] = counter
				else:
					visited[position] = counter
			else:
				minimum = counter - visited[position]
				pos = visited[position]
				visited[position] = counter
				flag = True
		else:
			visited[position] = counter
		counter += 1
	if flag:
		print(pos + 1, pos + minimum)
	else:
		print(-1)


T = int(input())
for _ in range(T):
	len = int(input())
	stt = str(input())
	da = {}
	da[0, 0] = 0
	a = 0
	b = 0
	indice1 = 0
	indice2 = 0
	res = float('inf')
	for j in range(len):
		if stt[j] == 'L':
			a -= 1
		elif stt[j] == 'R':
			a += 1
		elif stt[j] == 'U':
			b += 1
		else:
			b -= 1
		if (a, b) not in da:
			da[a, b] = j + 1
		else:
			if j + 1 - da[a, b] + 1 < res:
				indice1 = da[a, b]
				indice2 = j + 1
				res = j + 1 - da[a, b] + 1
			da[a, b] = j + 1
	if res != float('inf'):
		print(indice1 + 1, indice2)
	else:
		print(-1)


import math
for ii in range(int(input())):
	n = int(input())
	s = input()
	dic = {}
	dic['X0Y0'] = 0
	curr = [0, 0]
	size = math.inf
	for i in range(len(s)):
		if s[i] == 'L':
			curr[0] -= 1
		if s[i] == 'R':
			curr[0] += 1
		if s[i] == 'U':
			curr[1] += 1
		if s[i] == 'D':
			curr[1] -= 1
		a = 'X' + str(curr[0]) + 'Y' + str(curr[1])
		if a not in dic:
			dic[a] = i + 1
		else:
			if i - dic[a] + 1 < size:
				l = dic[a]
				r = i
				size = r - l + 1
			dic[a] = i + 1
	if math.isfinite(size):
		print(l + 1, r + 1)
	else:
		print(-1)


import collections, heapq

def main():
	T = int(input().strip())
	for _ in range(T):
		n = int(input().strip())
		s = input().strip()
		walked = set([(0, 0)])
		d = {(0, 0): 0}
		d2 = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}
		cur = [0, 0]
		minL = float('inf')
		res = [None, None]
		for (i, c) in enumerate(s, 1):
			cur = [cur[0] + d2[c][0], cur[1] + d2[c][1]]
			if tuple(cur) in walked and minL > i - d[tuple(cur)]:
				minL = i - d[tuple(cur)]
				res = [d[tuple(cur)] + 1, i]
			walked.add(tuple(cur))
			d[tuple(cur)] = i
		if res[0]:
			print(res[0], res[1])
		else:
			print('-1')
main()


tests = int(input())
MAX_VAL = 2 * 100000.0 + 1

def trans(pos):
	return '{}/{}'.format(pos[0], pos[1])

def untrans(pos):
	pos = [int(x) for x in pos.split('/')]
for _ in range(tests):
	n = int(input())
	moves = input()
	pos = [0, 0]
	visited = {}
	index = 0
	minDist = MAX_VAL
	minPos = [None, None]
	visited[trans(pos)] = index
	for m in moves:
		if m == 'R':
			pos[0] += 1
		elif m == 'L':
			pos[0] -= 1
		elif m == 'U':
			pos[1] += 1
		else:
			pos[1] -= 1
		index += 1
		pos_str = trans(pos)
		if pos_str in visited:
			dist = index - visited[pos_str]
			if dist < minDist:
				minDist = dist
				minPos = [visited[pos_str] + 1, index]
		visited[pos_str] = index
	if minPos[0]:
		print(' '.join([str(x) for x in minPos]))
	else:
		print(-1)


import sys
input = sys.stdin.readline
inf = int(10000000000.0)
t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input().strip()
	(x, y) = (0, 0)
	l1 = -1
	d = {(x, y): 0}
	small = inf
	(l, h) = (-1, 0)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y -= 1
		else:
			y += 1
		if (x, y) in d:
			if i + 1 - d[x, y] < small:
				small = i + 1 - d[x, y]
				l = i - small + 2
				h = i + 1
		d[x, y] = i + 1
	if small == inf:
		print(-1)
	else:
		print(l, h)


t = int(input())
for case in range(t):
	n = int(input())
	s = input()
	deta_sum = []
	for i in range(n + 1):
		deta_sum.append([0] * 2)
	for (i, ch) in enumerate(s, start=1):
		for j in range(2):
			deta_sum[i][j] = deta_sum[i - 1][j]
		if ch == 'L':
			deta_sum[i][0] += 1
		elif ch == 'R':
			deta_sum[i][0] -= 1
		elif ch == 'U':
			deta_sum[i][1] += 1
		else:
			deta_sum[i][1] -= 1
	isv = dict()
	isv[0, 0] = 0
	ans = 1000000000
	l = 0
	r = 0
	for i in range(1, n + 1):
		tmp = isv.get((deta_sum[i][0], deta_sum[i][1]), -1)
		if tmp != -1 and i - tmp < ans:
			ans = i - tmp
			l = tmp + 1
			r = i
		isv[deta_sum[i][0], deta_sum[i][1]] = i
	if ans != 1000000000:
		print(l, r)
	else:
		print('-1')


def check(n, s):
	d = dict()
	(x, y) = (0, 0)
	d[x, y] = 0
	(l, r) = (-1, n)
	for i in range(n):
		c = s[i]
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		if (x, y) in d and i - d[x, y] < r - l:
			(l, r) = (d[x, y], i)
		d[x, y] = i + 1
	if l != -1:
		return (l + 1, r + 1)
	return (-1,)
for _ in range(int(input())):
	n = int(input())
	s = input()
	print(*check(n, s))


for _ in range(int(input())):
	n = int(input())
	x = input()
	pre = [0 for i in range(n + 1)]
	for i in range(n):
		if x[i] == 'L':
			pre[i + 1] = pre[i] - 1
		elif x[i] == 'R':
			pre[i + 1] = pre[i] + 1
		elif x[i] == 'U':
			pre[i + 1] = pre[i] + int(1000000000.0)
		else:
			pre[i + 1] = pre[i] - int(1000000000.0)
	ans = -1
	l = r = -1
	d = dict()
	for i in range(n + 1):
		if pre[i] not in d:
			d[pre[i]] = i
		else:
			if ans == -1 or i - d[pre[i]] < ans:
				ans = i - d[pre[i]]
				l = d[pre[i]] + 1
				r = i
			d[pre[i]] = i
	if ans == -1:
		print(ans)
	else:
		print(l, r)


t = int(input())
for i in range(t):
	z = int(input())
	s = input()
	x = 0
	y = 0
	W = {}
	W[0, 0] = 0
	m = 10 ** 10
	c = -1
	d = -1
	for i in range(z):
		if s[i] == 'L':
			x -= 1
			if (x, y) in W:
				if m > i - W[x, y]:
					m = i - W[x, y]
					c = W[x, y] + 1
					d = i + 1
			W[x, y] = i + 1
		elif s[i] == 'R':
			x += 1
			if (x, y) in W:
				if m > i - W[x, y]:
					m = i - W[x, y]
					c = W[x, y] + 1
					d = i + 1
			W[x, y] = i + 1
		elif s[i] == 'D':
			y -= 1
			if (x, y) in W:
				if m > i - W[x, y]:
					m = i - W[x, y]
					c = W[x, y] + 1
					d = i + 1
			W[x, y] = i + 1
		else:
			y += 1
			if (x, y) in W:
				if m > i - W[x, y]:
					m = i - W[x, y]
					c = W[x, y] + 1
					d = i + 1
			W[x, y] = i + 1
	if c > -1 and d > -1:
		print(c, d)
	else:
		print(-1)


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


INF = float('inf')
DIR = {'L': -1, 'R': 1, 'U': -1, 'D': 1}
for _ in range(int(input())):
	input()
	s = input()
	last = {(0, 0): 0}
	curX = curY = 0
	retI = retJ = INF
	sz = INF
	for (i, ch) in enumerate(s):
		if ch in 'LR':
			curX += DIR[ch]
		else:
			curY += DIR[ch]
		if (curX, curY) in last:
			prev = last[curX, curY]
			if i - prev + 1 <= sz:
				sz = i - prev + 1
				(retI, retJ) = (prev + 1, i + 1)
		last[curX, curY] = i + 1
	print('%d %d' % (retI, retJ) if sz != INF else -1)


import math, string, itertools, fractions, heapq, collections, re, array, bisect, sys, copy, functools
inf = 10 ** 20
eps = 1.0 / 10 ** 10
mod = 10 ** 9 + 7
mod2 = 998244353
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = [(-1, 0), (-1, 1), (0, 1), (1, 1), (1, 0), (1, -1), (0, -1), (-1, -1)]

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

def LLI():
	return [list(map(int, l.split())) for l in sys.stdin.readlines()]

def LI_():
	return [int(x) - 1 for x in sys.stdin.readline().split()]

def LF():
	return [float(x) for x in sys.stdin.readline().split()]

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

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

def F():
	return float(sys.stdin.readline())

def S():
	return input()

def pf(s):
	return print(s, flush=True)

def pe(s):
	return print(str(s), file=sys.stderr)

def JA(a, sep):
	return sep.join(map(str, a))

def JAA(a, s, t):
	return s.join((t.join(map(str, b)) for b in a))

def IF(c, t, f):
	return t if c else f

def YES(c):
	return IF(c, 'YES', 'NO')

def Yes(c):
	return IF(c, 'Yes', 'No')

def main():
	t = I()
	rr = []
	for _ in range(t):
		n = I()
		s = S()
		t = inf
		l = r = -1
		c = {}
		c[0, 0] = 0
		i = j = 0
		for (k, u) in enumerate(s):
			if u == 'U':
				i -= 1
			elif u == 'D':
				i += 1
			elif u == 'L':
				j -= 1
			else:
				j += 1
			if (i, j) in c:
				m = k - c[i, j]
				if t > m:
					t = m
					l = c[i, j]
					r = k
			c[i, j] = k + 1
		if t == inf:
			rr.append(-1)
		else:
			rr.append(JA([l + 1, r + 1], ' '))
	return JA(rr, '\n')
print(main())


t = int(input())
for _ in range(t):
	n = int(input())
	arr = list(input())
	curr = [0, 0]
	visited = {tuple(curr): 0}
	dist = float('inf')
	le = -1
	re = -1
	for i in range(n):
		(x, y) = curr
		if arr[i] == 'L':
			x -= 1
		elif arr[i] == 'R':
			x += 1
		elif arr[i] == 'U':
			y += 1
		elif arr[i] == 'D':
			y -= 1
		curr = [x, y]
		if tuple(curr) in visited:
			d = i - visited[tuple(curr)] + 1
			if d < dist:
				dist = d
				le = visited[tuple(curr)]
				re = i
		visited[tuple(curr)] = i + 1
	if dist != float('inf'):
		print(le + 1, re + 1)
	else:
		print(-1)


import sys
input = sys.stdin.readline
t = int(input())

def bo(h, v):
	return str(h) + '*' + str(v)
while t > 0:
	t -= 1
	n = int(input())
	a = list(input())
	h = 0
	v = 0
	d = {}
	cd = []
	d[bo(0, 0)] = -1
	maxi = 99999999999999
	for i in range(n):
		if a[i] == 'L':
			v -= 1
		if a[i] == 'R':
			v += 1
		if a[i] == 'U':
			h += 1
		if a[i] == 'D':
			h -= 1
		if bo(h, v) in d:
			if maxi > i - d[bo(h, v)]:
				maxi = i - d[bo(h, v)]
				cd = [d[bo(h, v)] + 2, i + 1]
		d[bo(h, v)] = i
	if len(cd) == 0:
		print(-1)
	else:
		print(*cd)


for i in range(int(input())):
	n = int(input())
	s = input()
	d = dict()
	d[0, 0] = 1
	x = y = 0
	level = 2
	Mi = float('inf')
	for j in range(n):
		if s[j] == 'L':
			x -= 1
			if d.get((x, y), -1) == -1:
				d[x, y] = level
			else:
				tt = level - d[x, y]
				if tt < Mi:
					Mi = tt
					ind1 = d[x, y]
					ind2 = level - 1
				d[x, y] = level
		elif s[j] == 'R':
			x += 1
			if d.get((x, y), -1) == -1:
				d[x, y] = level
			else:
				tt = level - d[x, y]
				if tt < Mi:
					Mi = tt
					ind1 = d[x, y]
					ind2 = level - 1
				d[x, y] = level
		elif s[j] == 'D':
			y -= 1
			if d.get((x, y), -1) == -1:
				d[x, y] = level
			else:
				tt = level - d[x, y]
				if tt < Mi:
					Mi = tt
					ind1 = d[x, y]
					ind2 = level - 1
				d[x, y] = level
		else:
			y += 1
			if d.get((x, y), -1) == -1:
				d[x, y] = level
			else:
				tt = level - d[x, y]
				if tt < Mi:
					Mi = tt
					ind1 = d[x, y]
					ind2 = level - 1
				d[x, y] = level
		level += 1
	if Mi != float('inf'):
		print(ind1, ind2)
	else:
		print(-1)


t = int(input())
while t > 0:
	n = int(input())
	seq = input()
	dict = {}
	h = v = 0
	L = R = -1
	dis = 300000
	dict[0, 0] = 0
	possible = False
	for i in range(n):
		if seq[i] == 'L':
			h -= 1
		elif seq[i] == 'R':
			h += 1
		elif seq[i] == 'U':
			v += 1
		else:
			v -= 1
		tup = (h, v)
		if tup in dict:
			l = dict[tup] + 1
			r = i + 1
			if r - l + 1 < dis:
				L = l
				R = r
				dis = r - l + 1
			dict[tup] = i + 1
			possible = True
		else:
			dict[tup] = i + 1
	if possible:
		print(L, R)
	else:
		print('-1')
	t -= 1


testCase = int(input())
for _ in range(testCase):
	length = int(input())
	path = input()
	cordDic = {(0, 0): -1}
	x = 0
	y = 0
	idx = 0
	start = -1
	end = -1
	min = 2 ** 31
	for i in path:
		if i == 'L':
			x -= 1
		if i == 'R':
			x += 1
		if i == 'U':
			y -= 1
		if i == 'D':
			y += 1
		if (x, y) in cordDic:
			s = cordDic[x, y] + 1
			if idx - s < min:
				start = s
				end = idx
				min = end - start
		cordDic[x, y] = idx
		idx += 1
	if start != -1:
		print(start + 1, end + 1)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	(x, y) = (0, 0)
	(l, r) = (-1, n)
	d[x, y] = -1
	for (i, ch) in enumerate(s):
		if ch == 'L':
			x += 1
		elif ch == 'R':
			x -= 1
		elif ch == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d.keys():
			if i - d[x, y] < r - l:
				l = d[x, y] + 1
				r = i
		d[x, y] = i
	if l == -1:
		print(l)
	else:
		print(l + 1, r + 1)


import sys
input = sys.stdin.readline
dx = [-1, 1, 0, 0]
dy = [0, 0, 1, -1]
R = {'L': 0, 'R': 1, 'U': 2, 'D': 3}
T = int(input())
for _ in range(T):
	x = y = 0
	N = int(input())
	Path = input().rstrip()
	vst = {(0, 0): 0}
	ans = []
	for i in range(N):
		r = R[Path[i]]
		x += dx[r]
		y += dy[r]
		if (x, y) in vst:
			w = i - vst[x, y]
			ans.append((w, vst[x, y] + 1, i + 1))
		vst[x, y] = i + 1
	ans.sort()
	if ans:
		print(ans[0][1], ans[0][2])
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	dic = {}
	(x, y) = (0, 0)
	dic[0, 0] = [0]
	least = 10000000
	res = []
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		try:
			if dic[x, y]:
				dic[x, y].append(i + 1)
				temp = dic[x, y][-1] - dic[x, y][-2]
				if temp < least:
					least = dic[x, y][-1] - dic[x, y][-2]
					res = [dic[x, y][-2], dic[x, y][-1]]
		except KeyError:
			dic[x, y] = [i + 1]
	if len(res) > 1:
		print(res[0] + 1, res[1])
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(l, r) = (-1, n)
	(x, y, vis) = (0, 0, {(0, 0): 0})
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in vis.keys():
			if i - vis[x, y] + 1 < r - l + 1:
				l = vis[x, y]
				r = i
		vis[x, y] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


T = int(input())
t = 0
while t < T:
	N = int(input())
	s = input()
	x = 0
	y = 0
	risultato = float('INF')
	trovato = False
	P = {(x, y): 0}
	n = 0
	a = N
	b = N
	while n < N:
		c = s[n]
		if c == 'U':
			y += 1
		if c == 'D':
			y -= 1
		if c == 'L':
			x -= 1
		if c == 'R':
			x += 1
		if (x, y) in P:
			if n + 1 - P[x, y] < risultato:
				a = P[x, y] + 1
				b = n + 1
				risultato = n + 1 - P[x, y]
				trovato = True
		P[x, y] = n + 1
		n += 1
	if trovato:
		print(a, b)
	else:
		print(-1)
	t += 1


for t in range(int(input())):
	n = int(input())
	path = list(input())
	d = {'[0, 0]': [0]}
	pos = [0, 0]
	min_path = float('inf')
	ans = None
	flag = False
	for i in range(n):
		if path[i] == 'L':
			pos = [pos[0] - 1, pos[1]]
		elif path[i] == 'R':
			pos = [pos[0] + 1, pos[1]]
		elif path[i] == 'U':
			pos = [pos[0], pos[1] + 1]
		else:
			pos = [pos[0], pos[1] - 1]
		try:
			d[str(pos)].append(i + 1)
			if d[str(pos)][-1] - d[str(pos)][-2] + 1 < min_path:
				flag = True
				min_path = d[str(pos)][-1] - d[str(pos)][-2] + 1
				ans = (d[str(pos)][-2] + 1, d[str(pos)][-1])
			del d[str(pos)]
			d[str(pos)] = [i + 1]
		except KeyError:
			d[str(pos)] = [i + 1]
	if flag:
		print(*ans)
	else:
		print(-1)


m = int(input())
for xx in range(m):
	n = int(input())
	s = str(input())
	x = 0
	y = 0
	d = {(x, y): 0}
	wyn = [0, 0]
	curr_min = 999999999999
	for z in range(n):
		if s[z] == 'L':
			x += 1
		elif s[z] == 'R':
			x -= 1
		elif s[z] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			if z - d[x, y] < curr_min:
				wyn = [d[x, y], z]
				curr_min = z - d[x, y]
		d[x, y] = z + 1
	if wyn == [0, 0]:
		print(-1)
	else:
		print(wyn[0] + 1, wyn[1] + 1)


t = int(input())
for i in range(t):
	x = 0
	y = 0
	r = 0
	path = {}
	flag = 0
	min = 10 ** 10
	path[x, y] = r
	n = int(input())
	str = input()
	for st in str:
		r += 1
		if st == 'L':
			x -= 1
		elif st == 'R':
			x += 1
		elif st == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in path.keys():
			flag = 1
			l = path.get((x, y))
			if r - l + 1 < min:
				min = r - l + 1
				lt = l + 1
				rt = r
		path[x, y] = r
	if flag == 0:
		print(-1)
	else:
		print(lt, rt)


import sys
from collections import defaultdict

def input():
	return sys.stdin.readline().strip()

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def list3d(a, b, c, d):
	return [[[d] * c for j in range(b)] for i in range(a)]

def list4d(a, b, c, d, e):
	return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]

def ceil(x, y=1):
	return int(-(-x // y))

def INT():
	return int(input())

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

def LIST(N=None):
	return list(MAP()) if N is None else [INT() for i in range(N)]

def Yes():
	print('Yes')

def No():
	print('No')

def YES():
	print('YES')

def NO():
	print('NO')
INF = 10 ** 18
MOD = 10 ** 9 + 7
for _ in range(INT()):
	N = INT()
	S = input()
	D = defaultdict(lambda : -INF)
	mn = INF
	ans = ()
	cur = (0, 0)
	D[cur] = 0
	for (i, s) in enumerate(S):
		(x, y) = cur
		if s == 'L':
			cur = (x - 1, y)
		elif s == 'R':
			cur = (x + 1, y)
		elif s == 'D':
			cur = (x, y - 1)
		else:
			cur = (x, y + 1)
		dist = i - D[cur]
		if dist < mn:
			mn = dist
			ans = (D[cur] + 1, i + 1)
		D[cur] = i + 1
	if ans:
		print(*ans)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	di = {}
	di[x, y] = 0
	sol = []
	c = n
	for i in range(0, n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in di:
			b = i - di[x, y]
			if b < c:
				c = b
				sol = [di[x, y] + 1, i + 1]
		di[x, y] = i + 1
	if sol:
		print(*sol)
	else:
		print(-1)


for _ in range(int(input())):
	N = int(input())
	s = input()
	(x, y) = (0, 0)
	mp = dict()
	mp[0, 0] = -1
	(minl, minr) = (-1, 2 * N)
	for (it, ch) in enumerate(s):
		if ch == 'L':
			x -= 1
		if ch == 'R':
			x += 1
		if ch == 'D':
			y -= 1
		if ch == 'U':
			y += 1
		if (x, y) in mp:
			if minr - minl > it - mp[x, y]:
				minl = mp[x, y]
				minr = it
		mp[x, y] = it
	if minr == 2 * N:
		print(-1)
	else:
		print(minl + 2, minr + 1)


T = int(input())
for _ in range(T):
	N = int(input())
	s = input()
	x = 0
	y = 0
	d = dict()
	d[x, y] = -1
	m = 1000000
	a = 0
	b = 0
	for i in range(N):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y -= 1
		else:
			y += 1
		if (x, y) in d.keys():
			if m > i - d[x, y]:
				m = i - d[x, y]
				a = d[x, y]
				b = i
		d[x, y] = i
	if m == 1000000:
		m = -1
		print(m)
	else:
		print(a + 2, b + 1)


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	d = {}
	d[0, 0] = -1
	m = 999999
	a = -1
	b = -1
	x = 0
	y = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if d.get((x, y)) != None:
			if i - d[x, y] < m:
				m = i - d[x, y]
				a = d[x, y] + 1
				b = i
		d[x, y] = i
	if m == 999999:
		print(-1)
	else:
		print(a + 1, b + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	coord = {(0, 0): 0}
	x = 0
	y = 0
	length = 10 ** 7
	substr = (-1, -1)
	i = 1
	for letter in s:
		if letter == 'L':
			x -= 1
		elif letter == 'R':
			x += 1
		elif letter == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in coord:
			if i - coord[x, y] < length:
				length = i - coord[x, y]
				substr = (coord[x, y] + 1, i)
		coord[x, y] = i
		i += 1
	if substr == (-1, -1):
		print(-1)
	else:
		print(*substr)


dico = {'R': (1, 0), 'L': (-1, 0), 'U': (0, 1), 'D': (0, -1)}
rdico = {'R': (-1, 0), 'L': (1, 0), 'U': (0, -1), 'D': (0, 1)}

def make_move(x, y, m, fn=False):
	if not fn:
		return (x + dico[m][0], y + dico[m][1])
	return (x + rdico[m][0], y + rdico[m][1])

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		s = input()
		dico = {'0:0': 0}
		(x, y) = (0, 0)
		sols = []
		for xi in range(n):
			(x, y) = make_move(x, y, s[xi])
			o = str(x) + ':' + str(y)
			if o in dico:
				sols.append((xi - dico[o] + 1, dico[o], xi))
			dico[o] = xi + 1
		sols.sort(key=lambda x: x[0])
		if len(sols) == 0:
			print(-1)
			continue
		print(sols[0][1] + 1, sols[0][2] + 1)
main()


import sys
t = int(input())
for test in range(t):
	n = int(input())
	path = list(input())
	d = {}
	d[0, 0] = 1
	ans = []
	curr = [0, 0]
	for i in range(n):
		if path[i] == 'L':
			curr[0] -= 1
		elif path[i] == 'R':
			curr[0] += 1
		elif path[i] == 'U':
			curr[1] += 1
		else:
			curr[1] -= 1
		if (curr[0], curr[1]) not in d:
			d[curr[0], curr[1]] = i + 2
		else:
			ans.append((d[curr[0], curr[1]], i + 1))
			d[curr[0], curr[1]] = i + 2
	minn = sys.maxsize
	rr = 0
	ll = 0
	if len(ans) == 0:
		print(-1)
		continue
	for (l, r) in ans:
		if r - l + 1 < minn:
			minn = r - l + 1
			rr = r
			ll = l
	print(ll, rr)


t = int(input())

def k(a):
	return a[1] - a[0] + 1
for _ in range(t):
	n = int(input())
	s = input()
	d = dict()
	x = 0
	y = 0
	d[x, y] = 0
	l = []
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in d:
			l.append((d[x, y] + 1, i + 1))
			d[x, y] = i + 1
		else:
			d[x, y] = i + 1
	l.sort(key=k)
	if l == []:
		print(-1)
	else:
		print(l[0][0], l[0][1])


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	seq = input()
	H = 0
	V = 0
	pos = defaultdict(list)
	pos[0, 0].append(0)
	for i in range(len(seq)):
		if seq[i] == 'L':
			H -= 1
		elif seq[i] == 'R':
			H += 1
		elif seq[i] == 'U':
			V -= 1
		else:
			V += 1
		pos[H, V].append(i + 1)
	if all((len(it) <= 1 for (v, it) in pos.items())):
		print(-1)
	else:
		mini1 = 0
		mini2 = 0
		mindiff = 10 ** 7
		for (key, val) in pos.items():
			for i in range(len(val) - 1):
				if val[i + 1] - val[i] < mindiff:
					mini1 = val[i]
					mini2 = val[i + 1]
					mindiff = val[i + 1] - val[i]
		print(mini1 + 1, mini2)


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

def solve():
	n = int(input())
	s = input()
	d = {(0, 0): -1}
	ll = -1
	(x, y) = (0, 0)
	res = (-1, -1)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) not in d:
			d[x, y] = i
		else:
			dist = i - d[x, y]
			if dist < ll or ll == -1:
				ll = dist
				res = (d[x, y] + 2, i + 1)
			if dist == 2:
				break
			d[x, y] = i
	if ll != -1:
		print(*res)
	else:
		print(ll)

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


import math
t = int(input())
vect = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
for _ in range(t):
	n = int(input())
	s = str(input())
	m = {'0+0': 0}
	xy = [0, 0]
	ll = n + 2
	(l, r) = (0, 0)
	for i in range(n):
		xy[0] += vect[s[i]][0]
		xy[1] += vect[s[i]][1]
		hesh = str(xy[0]) + '+' + str(xy[1])
		if hesh in m:
			if i + 1 - m[hesh] < ll:
				ll = i + 1 - m[hesh]
				l = m[hesh] + 1
				r = i + 1
		m[hesh] = i + 1
	if ll == n + 2:
		print(-1)
	else:
		print(l, r)


import sys
t = int(sys.stdin.readline())
for i in range(t):
	n = int(sys.stdin.readline())
	s = sys.stdin.readline().strip()
	x_arr = [0]
	y_arr = [0]
	for g in range(n):
		if s[g] == 'L':
			x_arr.append(x_arr[g] - 1)
			y_arr.append(y_arr[g])
		elif s[g] == 'R':
			x_arr.append(x_arr[g] + 1)
			y_arr.append(y_arr[g])
		elif s[g] == 'U':
			x_arr.append(x_arr[g])
			y_arr.append(y_arr[g] + 1)
		else:
			x_arr.append(x_arr[g])
			y_arr.append(y_arr[g] - 1)
	xe = x_arr[-1]
	ye = y_arr[-1]
	ans = n + 1
	tmp = [1, n]
	d = {}
	d[0, 0] = 0
	for k in range(n):
		ind = k + 1
		if (x_arr[ind], y_arr[ind]) in d:
			num = d[x_arr[ind], y_arr[ind]]
			if ind - num < ans:
				ans = ind - num
				tmp[0] = num + 1
				tmp[1] = ind
		d[x_arr[ind], y_arr[ind]] = ind
	if ans == n + 1:
		print(-1)
	else:
		print(tmp[0], tmp[1])


import sys
input = sys.stdin.readline
from collections import *
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()[:-1]
	M = 10 ** 18
	(x, y) = (0, 0)
	d = defaultdict(int)
	d[10 ** 6 * x + y] = 1
	(l, r) = (-1, -1)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if 10 ** 6 * x + y in d and i + 1 - d[10 ** 6 * x + y] < M:
			M = i + 1 - d[10 ** 6 * x + y]
			(l, r) = (d[10 ** 6 * x + y], i + 1)
		d[10 ** 6 * x + y] = i + 2
	if M == 10 ** 18:
		print(-1)
	else:
		print(l, r)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	flag = 0
	d[0, 0] = 1
	point = (0, 0)
	x = 100000000
	z = [0, 0]
	for i in range(n):
		if s[i] == 'R':
			point = (point[0] + 1, point[1])
		elif s[i] == 'L':
			point = (point[0] - 1, point[1])
		elif s[i] == 'U':
			point = (point[0], point[1] + 1)
		elif s[i] == 'D':
			point = (point[0], point[1] - 1)
		if point in d:
			t = i + 1 - d[point]
			if t < x:
				x = t
				z = [d[point], i + 1]
			d[point] = i + 2
			flag = 1
		else:
			d[point] = i + 2
	if flag == 1:
		print(*z)
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	x = 0
	y = 0
	d[x, y] = [0]
	m1 = -1
	m2 = -1
	c = 0
	for i in s:
		c += 1
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		try:
			d[x, y].append(c)
			if m1 == -1:
				m2 = d[x, y][-1]
				m1 = d[x, y][-2]
			if d[x, y][-1] - d[x, y][-2] < m2 - m1:
				m2 = d[x, y][-1]
				m1 = d[x, y][-2]
		except:
			d[x, y] = [c]
	if m1 != -1:
		print(str(m1 + 1) + ' ' + str(m2))
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {(0, 0): [0]}
	(x, y) = (0, 0)
	(l, r) = (0, 2 * n)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			d[x, y].append(i + 1)
			if d[x, y][-1] - d[x, y][-2] <= r - l:
				r = d[x, y][-1]
				l = d[x, y][-2]
		else:
			d[x, y] = [i + 1]
	if r - l > n:
		print(-1)
	else:
		print(l + 1, ' ', r)


for _ in range(int(input())):
	n = int(input())
	path = input()
	way = dict()
	way[0, 0] = 0
	(x, y) = (0, 0)
	(best_l, best_r) = (-1000000000.0, 0)
	for (i, p) in enumerate(path):
		if p == 'U':
			(new_x, new_y) = (x, y + 1)
		elif p == 'D':
			(new_x, new_y) = (x, y - 1)
		elif p == 'R':
			(new_x, new_y) = (x + 1, y)
		else:
			(new_x, new_y) = (x - 1, y)
		new_pos = (new_x, new_y)
		if new_pos in way:
			prev_ind = way[new_pos]
			if i + 1 - prev_ind < best_r - best_l:
				(best_r, best_l) = (i + 1, prev_ind)
		way[new_pos] = i + 1
		(x, y) = (new_x, new_y)
	if best_l < 0:
		print(-1)
	else:
		print(best_l + 1, best_r)


for _ in range(int(input())):
	d = {(0, 0): 0}
	n = int(input())
	s = input()
	(u, l) = (0, 0)
	(lo, up) = (-1, -1)
	ma = 10 ** 10
	for i in range(n):
		if s[i] == 'L':
			l -= 1
			if (l, u) in d.keys():
				(x, y) = (d[l, u], i)
				if abs(y - x) < ma:
					ma = abs(y - x)
					lo = d[l, u]
					up = i
				d[l, u] = i + 1
			else:
				d[l, u] = i + 1
		elif s[i] == 'R':
			l += 1
			if (l, u) in d.keys():
				(x, y) = (d[l, u], i)
				if abs(y - x) < ma:
					ma = abs(y - x)
					lo = d[l, u]
					up = i
				d[l, u] = i + 1
			else:
				d[l, u] = i + 1
		elif s[i] == 'U':
			u += 1
			if (l, u) in d.keys():
				(x, y) = (d[l, u], i)
				if abs(y - x) < ma:
					ma = abs(y - x)
					lo = d[l, u]
					up = i
				d[l, u] = i + 1
			else:
				d[l, u] = i + 1
		else:
			u -= 1
			if (l, u) in d.keys():
				(x, y) = (d[l, u], i)
				if abs(y - x) < ma:
					ma = abs(y - x)
					lo = d[l, u]
					up = i
				d[l, u] = i + 1
			else:
				d[l, u] = i + 1
	if lo == -1 and up == -1:
		print(-1)
	else:
		print(lo + 1, up + 1)


import math
t = int(input())
ns = []
arrs = []
for _ in range(t):
	ns.append(int(input()))
	nums = list(input())
	arrs.append(nums)
for i in range(t):
	n = ns[i]
	arr = arrs[i].copy()
	pos = [0, 0]
	m = {(0, 0): -1}
	smallest = math.inf
	coords = [-1, -1]
	for j in range(n):
		move = arr[j]
		if move == 'L':
			pos[0] -= 1
		elif move == 'R':
			pos[0] += 1
		elif move == 'U':
			pos[1] += 1
		else:
			pos[1] -= 1
		if tuple(pos) not in m.keys():
			m[tuple(pos)] = j
		else:
			distance = j - m[tuple(pos)]
			if distance < smallest:
				smallest = distance
				coords = [m[tuple(pos)], j]
			m[tuple(pos)] = j
	if smallest == math.inf:
		print(-1)
	else:
		print(coords[0] + 2, coords[1] + 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	(cntx, cnty) = (0, 0)
	d = dict()
	d[0, 0] = 0
	ans = 10 ** 9
	for i in range(n):
		if s[i] == 'L':
			cntx -= 1
		elif s[i] == 'R':
			cntx += 1
		elif s[i] == 'U':
			cnty += 1
		else:
			cnty -= 1
		if (cntx, cnty) not in d:
			d[cntx, cnty] = i + 1
		else:
			if ans > i + 1 - d[cntx, cnty]:
				ans = i + 1 - d[cntx, cnty]
				k1 = i + 1
				k2 = d[cntx, cnty] + 1
			d[cntx, cnty] = i + 1
	if ans == 10 ** 9:
		print(-1)
	else:
		print(k2, k1)


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

def f(x):
	return x[2]
t = int(input())
for zz in range(t):
	n = int(input())
	s = input()
	dp = {}
	cp = [0, 0]
	ha = False
	i = 0
	dp[0, 0] = 0
	pa = []
	while i < n:
		move(cp, s[i], 1)
		i += 1
		tt = tuple(cp)
		if tt in dp:
			pa.append([dp[tt] + 1, i, i - dp[tt]])
			ha = True
		dp[tt] = i
	pa.sort(key=f)
	if not ha:
		print(-1)
	else:
		print(pa[0][0], pa[0][1])


t = int(input())
for _ in range(t):
	n = int(input())
	sl = list(input())
	a = 0
	b = 0
	dic = {}
	ans = float('inf')
	log = 0
	dic[0, 0] = 0
	for (idx, s) in enumerate(sl):
		if s == 'L':
			a -= 1
		elif s == 'R':
			a += 1
		elif s == 'U':
			b += 1
		else:
			b -= 1
		if (a, b) in dic:
			if idx - dic[a, b] < ans:
				ans = idx - dic[a, b]
				log = (dic[a, b] + 1, idx + 1)
				dic[a, b] = idx + 1
			else:
				dic[a, b] = idx + 1
		else:
			dic[a, b] = idx + 1
	else:
		if ans == float('inf'):
			print(-1)
		else:
			print(str(log[0]) + ' ' + str(log[1]))


from sys import stdin, stdout
from math import gcd, sqrt
from collections import deque
input = stdin.readline
R = lambda : map(int, input().split())
I = lambda : int(input())
S = lambda : input().rstrip('\n')
L = lambda : list(R())
P = lambda x: stdout.write(x)
lcm = lambda x, y: x * y // gcd(x, y)
hg = lambda x, y: (y + x - 1) // x * x
pw = lambda x: 0 if x == 1 else 1 + pw(x // 2)
chk = lambda x: chk(x // 2) if not x % 2 else True if x == 1 else False
sm = lambda x: (x ** 2 + x) // 2
N = 10 ** 9 + 7
for _ in range(I()):
	n = I()
	a = ['0p0']
	(x, y) = (0, 0)
	for i in S():
		if i == 'L':
			x += 1
		elif i == 'R':
			x -= 1
		elif i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		a += (str(x) + 'p' + str(y),)
	a = sorted(enumerate(a), key=lambda x: x[1])
	ans = N
	flg = False
	for i in range(n):
		if a[i][1] == a[i + 1][1]:
			if abs(a[i][0] - a[i + 1][0]) <= ans:
				m = sorted([a[i][0], a[i + 1][0]])
				flg = True
				ans = abs(a[i][0] - a[i + 1][0])
	if flg:
		print(m[0] + 1, m[1])
	else:
		print(-1)


t = int(input())
for you in range(t):
	n = int(input())
	s = input()
	ans = 5
	left = 0
	right = 0
	l = []
	z = 10 ** 9
	left = 0
	right = 0
	for i in s:
		if i == 'L':
			l.append(1)
		elif i == 'R':
			l.append(-1)
		elif i == 'U':
			l.append(z)
		else:
			l.append(-z)
	hashi = dict()
	hashi[0] = -1
	ans = z
	pref = 0
	for i in range(n):
		pref += l[i]
		if pref in hashi:
			if i - hashi[pref] < ans:
				ans = i - hashi[pref]
				left = hashi[pref] + 2
				right = i + 1
		hashi[pref] = i
	if ans == z:
		print(-1)
		continue
	print(left, right)


import sys
from collections import defaultdict
t = int(sys.stdin.readline())
for _ in range(t):
	dic = defaultdict(list)
	start = [0, 0]
	n = int(sys.stdin.readline())
	s = sys.stdin.readline()[:-1]
	dic[0, 0].append(0)
	for i in range(n):
		if s[i] == 'L':
			start[0] = start[0] - 1
			dic[tuple(start)].append(i + 1)
		elif s[i] == 'R':
			start[0] = start[0] + 1
			dic[tuple(start)].append(i + 1)
		elif s[i] == 'U':
			start[1] = start[1] + 1
			dic[tuple(start)].append(i + 1)
		else:
			start[1] = start[1] - 1
			dic[tuple(start)].append(i + 1)
	rem = [-1, -1]
	ans = float('inf')
	for i in dic:
		if len(dic[i]) >= 2:
			for j in range(len(dic[i]) - 1):
				if ans > dic[i][j + 1] - dic[i][j] + 1:
					ans = dic[i][j + 1] - dic[i][j] + 1
					rem = [dic[i][j], dic[i][j + 1]]
	if ans == float('inf'):
		print(-1)
	else:
		print(rem[0] + 1, rem[1])


d = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}
for _ in range(int(input())):
	n = int(input())
	s = input()
	points = {(0, 0): 0}
	pos = [0, 0]
	min_loop = n + 1
	for i in range(1, n + 1):
		pos[0] += d[s[i - 1]][0]
		pos[1] += d[s[i - 1]][1]
		if tuple(pos) in points:
			if i - points[tuple(pos)] < min_loop:
				min_loop = i - points[tuple(pos)]
				l = points[tuple(pos)] + 1
				r = i
		points[tuple(pos)] = i
	if min_loop == n + 1:
		print(-1)
	else:
		print(l, r)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	m = {}
	xy = [0, 0]
	m[tuple(xy)] = 0
	(l, r, pi) = (-1, n, 0)
	for i in range(0, n):
		if s[i] == 'L':
			xy[0] -= 1
		if s[i] == 'R':
			xy[0] += 1
		if s[i] == 'U':
			xy[1] += 1
		if s[i] == 'D':
			xy[1] -= 1
		txy = tuple(xy)
		if txy in m:
			if i - m[txy] < r - l:
				l = m[txy]
				r = i
		m[txy] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	ans = 10 ** 10
	(x, y) = (0, 0)
	(a, b) = (-1, -1)
	d[x, y] = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			if ans > i + 1 - d[x, y]:
				ans = i + 1 - d[x, y]
				(a, b) = (d[x, y] + 1, i + 1)
			d[x, y] = i + 1
		else:
			d[x, y] = i + 1
	if a == -1 or b == -1:
		print(-1)
	else:
		print(a, b)


import os
from io import BytesIO, IOBase
import sys
from collections import defaultdict, deque, Counter
from bisect import *
from math import sqrt, pi, ceil, log, inf, gcd
from itertools import permutations
from copy import deepcopy
from heapq import *
from sys import setrecursionlimit

def main():
	for _ in range(int(input())):
		n = int(input())
		a = input().strip()
		(l, r, x, y, f) = (0, n - 1, 0, 0, 1)
		b = {}
		b[0, 0] = 0
		for (j, i) in enumerate(a):
			x += (i == 'R') - (i == 'L')
			y += (i == 'U') - (i == 'D')
			if b.get((x, y)) != None:
				f = 0
				if r - l + 1 > j - b[x, y] + 1:
					r = j
					l = b[x, y]
			b[x, y] = j + 1
		if f:
			print(-1)
		else:
			print(l + 1, r + 1)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	s = list(input())
	visited = {}
	visited = defaultdict(lambda : [], visited)
	we = [0, 0]
	ans = float('inf')
	visited[0, 0] = [0]
	ansList = []
	for i in range(n):
		if s[i] == 'L':
			we[0] -= 1
		elif s[i] == 'R':
			we[0] += 1
		elif s[i] == 'U':
			we[1] += 1
		else:
			we[1] -= 1
		if visited[we[0], we[1]] == []:
			visited[we[0], we[1]].append(i + 1)
		else:
			temp = visited[we[0], we[1]].pop()
			ans = min(ans, i + 1 - temp)
			if ans == i + 1 - temp:
				ansList = [temp + 1, i + 1]
			visited[we[0], we[1]].append(temp)
			visited[we[0], we[1]].append(i + 1)
	if ans == float('inf'):
		print(-1)
	else:
		print(ansList[0], ansList[1])


for _ in range(int(input())):
	n = int(input())
	arr = input()
	x = 0
	y = 0
	check = {}
	cnt = 1
	minlen = -1
	rex = 0
	rey = 0
	check[str(x)] = {str(y): 0}
	for c in arr:
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		chk = check.get(str(x), {}).get(str(y), -1)
		if chk != -1:
			if minlen == -1 or minlen > cnt - chk:
				minlen = cnt - chk
				rex = chk + 1
				rey = cnt
		if str(x) not in check:
			check[str(x)] = {str(y): cnt}
		else:
			check[str(x)][str(y)] = cnt
		cnt += 1
	if minlen == -1:
		print(-1)
	else:
		print(f'{rex} {rey}')


def update_position(a, x, y):
	if a == 'L':
		x -= 1
	elif a == 'R':
		x += 1
	elif a == 'U':
		y += 1
	else:
		y -= 1
	return (x, y)
testCases = int(input())
for i1 in range(testCases):
	l = int(input())
	s = list(input())
	(x, y) = (0, 0)
	d = {(x, y): 0}
	k = 9e+18
	result = None
	for i2 in range(l):
		(x, y) = update_position(s[i2], x, y)
		if (x, y) in d.keys():
			if i2 - d[x, y] < k:
				result = [d[x, y] + 1, i2 + 1]
				k = i2 - d[x, y]
		d[x, y] = i2 + 1
	if result is None:
		print(-1)
	else:
		print(*result)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	m = {}
	cp = (0, 0)
	m[cp] = -1
	(l, r) = (-1, n)
	for i in range(len(s)):
		if s[i] == 'L':
			cp = (cp[0] - 1, cp[1])
		elif s[i] == 'R':
			cp = (cp[0] + 1, cp[1])
		elif s[i] == 'U':
			cp = (cp[0], cp[1] + 1)
		else:
			cp = (cp[0], cp[1] - 1)
		if cp in m and r - l + 1 > i - m[cp]:
			(l, r) = (m[cp] + 1, i)
		m[cp] = i
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


T = int(input())
move = {'L': -1, 'R': 1, 'U': -1, 'D': 1}
for t in range(T):
	ha = {}
	n = int(input())
	s = input()
	tmp = (0, 0)
	ha[tmp] = 0
	op = [-1, n]
	for i in range(n):
		if s[i] == 'L' or s[i] == 'R':
			tmp = (tmp[0] + move[s[i]], tmp[1])
		else:
			tmp = (tmp[0], move[s[i]] + tmp[1])
		if tmp in ha.keys():
			if i - ha[tmp] < op[1] - op[0]:
				op = [ha[tmp] + 1, i + 1]
		ha[tmp] = i + 1
	if op[1] - op[0] + 1 > n:
		print(-1)
	else:
		print(op[0], op[1])


from bisect import bisect_left as bl
from bisect import bisect_right as br
import heapq
import math
from collections import *
from functools import reduce, cmp_to_key
import sys
input = sys.stdin.readline

def factors(n):
	return sorted(set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0))))

def li():
	return [int(i) for i in input().rstrip('\n').split()]

def st():
	return input().rstrip('\n')

def val():
	return int(input().rstrip('\n'))

def li2():
	return [i for i in input().rstrip('\n').split(' ')]

def li3():
	return [int(i) for i in input().rstrip('\n')]
for _ in range(val()):
	n = val()
	s = st()
	d = {}
	curr = [0, 0]
	ans = float('inf')
	d[tuple(curr)] = -1
	currlist = []
	for (ind, i) in enumerate(s):
		if i == 'U':
			curr[1] += 1
		elif i == 'D':
			curr[1] -= 1
		elif i == 'R':
			curr[0] += 1
		else:
			curr[0] -= 1
		tup = tuple(curr)
		if tup in d:
			if ans > ind - d[tup] + 1:
				ans = ind - d[tup] + 1
				currlist = [d[tup] + 2, ind + 1]
		d[tup] = ind
	if not len(currlist):
		print(-1)
	else:
		print(*currlist)


import random
from bisect import bisect_left, bisect_right
from typing import List
import collections
import bisect
import itertools
import functools
from fractions import gcd
import heapq
from math import ceil, sqrt, floor
import sys
sys.setrecursionlimit(50000)
import collections
from collections import defaultdict, deque
import collections
import bisect
from collections import defaultdict, deque
import collections
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	move = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}
	dic = {(0, 0): 0}
	x = y = 0
	minlen = n
	for (i, c) in enumerate(s):
		x += move[c][0]
		y += move[c][1]
		if (x, y) in dic:
			dist = i - dic[x, y]
			if minlen > dist:
				minlen = dist
				minstart = dic[x, y] + 1
				minend = i + 1
		dic[x, y] = i + 1
	if minlen == n:
		print(-1)
	else:
		print(f'{minstart} {minend}')


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = 0
	y = 0
	rec1 = 0
	rec2 = 0
	board = {(0, 0): -1}
	minn = 10000000
	rec = -1
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in board:
			if minn > i - board[x, y]:
				minn = i - board[x, y]
				rec1 = i
				rec2 = board[x, y]
			board[x, y] = i
		else:
			board[x, y] = i
	if minn != 10000000:
		print(rec2 + 2, rec1 + 1)
	else:
		print(-1)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	tab = [[0, 0]]
	cp = [str([0, 0])]
	d = defaultdict(list)
	d[str([0, 0])] = [0]
	for i in range(n):
		if s[i] == 'L':
			val = [tab[-1][0] - 1, tab[-1][1]]
		if s[i] == 'R':
			val = [tab[-1][0] + 1, tab[-1][1]]
		if s[i] == 'U':
			val = [tab[-1][0], tab[-1][1] + 1]
		if s[i] == 'D':
			val = [tab[-1][0], tab[-1][1] - 1]
		tab.append(val)
		cp.append(str(val))
		d[str(val)].append(i + 1)
	if len(set(cp)) == n + 1:
		print(-1)
	else:
		(l, r, m) = (-1, -1, n)
		for k in d.keys():
			if len(d[k]) > 1:
				c = d[k]
				for i in range(1, len(c)):
					if c[i - 1] == 0:
						if c[i] - (c[i - 1] + 1) < m:
							m = c[i] - (c[i - 1] + 1)
							l = c[i - 1] + 1
							r = c[i]
					elif c[i] - c[i - 1] < m:
						m = c[i] - c[i - 1]
						l = c[i - 1] + 1
						r = c[i]
		print(l, r)


def main():

	def solve():
		n = int(input())
		mm = input()
		pps = {(0, 0): 0}
		pos = (0, 0)
		best = n + 1
		l = -1
		r = -1
		for (i, m) in enumerate(mm, 1):
			if m == 'L':
				pos = (pos[0] - 1, pos[1])
			elif m == 'R':
				pos = (pos[0] + 1, pos[1])
			elif m == 'U':
				pos = (pos[0], pos[1] + 1)
			else:
				pos = (pos[0], pos[1] - 1)
			if pos in pps and i - pps[pos] < best:
				best = i - pps[pos]
				l = pps[pos]
				r = i
			pps[pos] = i
		if l == -1:
			print(-1)
		else:
			print(l + 1, r)
	q = int(input())
	for _ in range(q):
		solve()
main()


t = int(input())
for _ in range(t):
	n = int(input())
	s = str(input())
	d = {}
	d[0, 0] = 0
	x = 0
	y = 0
	ind1 = 0
	ind2 = 0
	ans = float('inf')
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) not in d:
			d[x, y] = i + 1
		else:
			if i + 1 - d[x, y] + 1 < ans:
				ind1 = d[x, y]
				ind2 = i + 1
				ans = i + 1 - d[x, y] + 1
			d[x, y] = i + 1
	if ans != float('inf'):
		print(ind1 + 1, ind2)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	x = (0, 0)
	d = dict()
	d[x] = 0
	j = 0
	(ai, aj) = (-1, -1)
	ans = 99999999999999999
	for i in s:
		j += 1
		if i == 'D':
			x = (x[0] - 1, x[1])
			if d.get(x, -1) != -1:
				if ans > j - d.get(x) + 1:
					ans = j - d.get(x) + 1
					(ai, aj) = (d.get(x), j - 1)
			d[x] = j
		if i == 'R':
			x = (x[0], x[1] + 1)
			if d.get(x, -1) != -1:
				if ans > j - d.get(x) + 1:
					ans = j - d.get(x) + 1
					(ai, aj) = (d.get(x), j - 1)
			d[x] = j
		if i == 'U':
			x = (x[0] + 1, x[1])
			if d.get(x, -1) != -1:
				if ans > j - d.get(x) + 1:
					ans = j - d.get(x) + 1
					(ai, aj) = (d.get(x), j - 1)
			d[x] = j
		if i == 'L':
			x = (x[0], x[1] - 1)
			if d.get(x, -1) != -1:
				if ans > j - d.get(x) + 1:
					ans = j - d.get(x) + 1
					(ai, aj) = (d.get(x), j - 1)
			d[x] = j
	if ai == -1 and aj == -1:
		print(-1)
	else:
		print(ai + 1, aj + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	kk = dict()
	c1 = 0
	c2 = 0
	kk[0, 0] = -1
	mn = n + 100
	ptr1 = 1
	ptr2 = n
	for i in range(0, len(s)):
		if s[i] == 'L':
			c1 -= 1
		elif s[i] == 'R':
			c1 += 1
		elif s[i] == 'U':
			c2 += 1
		else:
			c2 -= 1
		if kk.get((c1, c2)) != None:
			t = i - kk[c1, c2]
			if t < mn:
				ptr1 = kk[c1, c2] + 1
				ptr2 = i
			mn = min(mn, t)
		kk[c1, c2] = i
	if mn == n + 100:
		print(-1)
	else:
		print(ptr1 + 1, ptr2 + 1)


import sys
sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep='\n')

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

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

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

def LLI(rows_number):
	return [LI() for _ in range(rows_number)]

def SI():
	return sys.stdin.readline()[:-1]
from collections import defaultdict

def main():
	inf = 10 ** 6
	t = II()
	for _ in range(t):
		n = II()
		s = SI()
		xytoi = defaultdict(list)
		x = y = 0
		for (i, c) in enumerate(s):
			xytoi[x, y].append(i)
			if c == 'L':
				x -= 1
			if c == 'R':
				x += 1
			if c == 'D':
				y -= 1
			if c == 'U':
				y += 1
		xytoi[x, y].append(n)
		l = r = -1
		mn = inf
		for ii in xytoi.values():
			if len(ii) < 2:
				continue
			for (i1, i2) in zip(ii, ii[1:]):
				d = i2 - i1
				if d < mn:
					mn = d
					l = i1 + 1
					r = i2
		if l == -1:
			print(-1)
		else:
			print(l, r)
main()


t = int(input())
for tests in range(t):
	size = input()
	data = input()
	updateX = {'L': -1, 'R': 1, 'U': 0, 'D': 0}
	updateY = {'L': 0, 'R': 0, 'U': 1, 'D': -1}
	minreq = len(data) + 2
	points = {(0, 0): 0}
	(x, y, l, r) = (0, 0, 0, 0)
	for (i, s) in enumerate(data):
		x += updateX[s]
		y += updateY[s]
		if (x, y) in points:
			j = points[x, y]
			if i + 1 - j < minreq:
				minreq = i + 1 - j
				l = j + 1
				r = i + 1
		points[x, y] = i + 1
	if minreq == len(data) + 2:
		print(-1)
	else:
		print(l, r)


import os
import sys
from atexit import register
from io import StringIO
sys.stdout = StringIO()
register(lambda : os.write(1, sys.stdout.getvalue().encode()))
import math
t = int(input())
dirs = {'U': (0, -1), 'D': (0, 1), 'L': (-1, 0), 'R': (1, 0)}
for _ in range(t):
	n = int(sys.stdin.readline())
	s = sys.stdin.readline().rstrip()
	pos = (0, 0)
	sums = {}
	sums[pos] = [0]
	for i in range(1, len(s) + 1):
		d = dirs[s[i - 1]]
		pos = (pos[0] + d[0], pos[1] + d[1])
		if pos not in sums:
			sums[pos] = []
		sums[pos].append(i)
	ret = (math.inf, 0, 0)
	for p in sums:
		for i in range(len(sums[p]) - 1):
			l = sums[p][i]
			r = sums[p][i + 1]
			if r - l < ret[0]:
				ret = (r - l, l, r)
	if ret[0] == math.inf:
		print(-1)
	else:
		print(ret[1] + 1, ret[2])


from sys import stdin, stdout
t = int(stdin.readline().strip())
for _ in range(t):
	n = int(stdin.readline().strip())
	(posX, posY) = (0, 0)
	posD = {(0, 0): [0]}
	for (i, c) in enumerate(stdin.readline().strip()):
		if c == 'L':
			posX -= 1
		elif c == 'R':
			posX += 1
		elif c == 'U':
			posY += 1
		elif c == 'D':
			posY -= 1
		posD.setdefault((posX, posY), []).append(i + 1)
	(a, b, c) = (0, 0, n + 1)
	for l in posD.values():
		i = 0
		while i + 1 < len(l):
			if l[i + 1] - l[i] < c:
				(a, b) = (l[i], l[i + 1])
				c = b - a
			i += 1
	if a == b:
		stdout.write('-1\n')
	else:
		stdout.write('{} {}\n'.format(a + 1, b))


import sys
import math
from collections import defaultdict as dd
mod = 1000000007
T = 1
T = int(sys.stdin.readline())
for _ in range(T):
	n = int(input())
	s = input()
	d = {'L': 'R', 'R': 'L', 'U': 'D', 'D': 'U'}
	l = []
	flg = 0
	ans = []
	for i in range(n):
		if len(l) and l[-1] == d[s[i]]:
			ans = [i, i + 1]
			flg = 1
			break
		l.append(s[i])
	if flg:
		print(*ans)
		continue
	di = {(0, 0): 0}
	(nx, ny) = (0, 0)
	m = n
	for i in range(n):
		if s[i] == 'L':
			nx -= 1
		elif s[i] == 'R':
			nx += 1
		elif s[i] == 'U':
			ny += 1
		else:
			ny -= 1
		if (nx, ny) in di:
			k = i + 1 - di[nx, ny] - 1
			if m > k:
				m = k
				ans = [di[nx, ny] + 1, i + 1]
		di[nx, ny] = i + 1
	if m == n:
		print(-1)
	else:
		print(*ans)


from collections import deque
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	pos = {(0, 0): -1}
	mini = float('INF')
	x = y = 0
	ans = []
	for (i, c) in enumerate(s):
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'D':
			y -= 1
		elif c == 'U':
			y += 1
		if (x, y) in pos:
			if i - pos[x, y] < mini:
				ans = [pos[x, y], i]
				mini = i - pos[x, y]
		pos[x, y] = i
	if len(ans):
		print(ans[0] + 2, ans[1] + 1)
	else:
		print(-1)


import sys
input = sys.stdin.readline

def prog():
	for _ in range(int(input())):
		n = int(input())
		path = input().strip()
		visited = {}
		curr_location = [0, 0]
		for i in range(1, n + 1):
			move = path[i - 1]
			location = tuple(curr_location)
			if location in visited:
				visited[location].append(i)
			else:
				visited[location] = [i]
			if move == 'L':
				curr_location[0] -= 1
			elif move == 'R':
				curr_location[0] += 1
			elif move == 'U':
				curr_location[1] += 1
			elif move == 'D':
				curr_location[1] -= 1
			new_location = tuple(curr_location)
			if new_location in visited:
				visited[new_location].append(i)
		cycles = {}
		for cycle in visited.values():
			if len(cycle) % 2 == 1:
				cycle.pop()
			for i in range(len(cycle) // 2):
				start = cycle[2 * i]
				stop = cycle[2 * i + 1]
				cycles[stop - start] = (start, stop)
		if len(cycles) == 0:
			print(-1)
		else:
			shortest = min(cycles)
			print(cycles[shortest][0], cycles[shortest][1])
prog()


for _ in range(int(input())):
	n = int(input())
	s = input()
	h = 0
	v = 0
	P = []
	D = {(0, 0): [-1]}
	l = list()
	for i in range(n):
		if s[i] == 'R':
			h += 1
		if s[i] == 'L':
			h -= 1
		if s[i] == 'U':
			v += 1
		if s[i] == 'D':
			v -= 1
		P.append((h, v))
		if (h, v) not in D.keys():
			D[h, v] = list()
		l = D[h, v]
		l.append(i)
		D[h, v] = l
	m = 1000000
	for i in D.keys():
		for j in range(1, len(D[i])):
			if D[i][j] - D[i][j - 1] < m:
				pair = [D[i][j - 1] + 2, D[i][j] + 1]
				m = D[i][j] - D[i][j - 1]
	if m != 1000000:
		print(pair[0], pair[1])
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	pts = {(0, 0): 1}
	(x, y) = (0, 0)
	(l, r) = (0, 10 ** 9)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if (x, y) in pts.keys():
			if r - l > i + 1 - pts[x, y]:
				(l, r) = (pts[x, y], i + 1)
			pts[x, y] = i + 2
		else:
			pts[x, y] = i + 2
	if l == 0 and r == 10 ** 9:
		print(-1)
	else:
		print(l, r)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	d = dict()
	d[0, 0] = 0
	Min = 10 ** 9
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d and Min > i + 1 - d[x, y]:
			Min = i + 1 - d[x, y]
			k1 = i + 1
			k2 = d[x, y] + 1
		d[x, y] = i + 1
	if Min == 10 ** 9:
		print(-1)
	else:
		print(k2, k1)


from math import inf
from collections import defaultdict

def solve(n, s):
	(x, y) = (0, 0)
	path = [(x, y)]
	for c in s:
		if c == 'L':
			x -= 1
		if c == 'R':
			x += 1
		if c == 'U':
			y += 1
		if c == 'D':
			y -= 1
		path.append((x, y))
	inds = defaultdict(list)
	for i in range(len(path)):
		inds[path[i]].append(i)
	minlen = inf
	for (key, value) in inds.items():
		if len(value) > 1:
			mindiff = inf
			for i in range(1, len(value)):
				currdiff = value[i] - value[i - 1]
				if currdiff < mindiff:
					mindiff = currdiff
					currans = (value[i - 1] + 1, value[i])
			if mindiff != inf:
				if mindiff < minlen:
					minlen = mindiff
					ans = currans
	if minlen == inf:
		print(-1)
	else:
		print(*ans)
for _ in range(int(input())):
	n = int(input())
	s = input()
	solve(n, s)


import sys
input = sys.stdin.readline

def getInt():
	return int(input())

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

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

def getStr():
	return input().strip()
t = getInt()
for _ in range(t):
	n = getInt()
	s = getStr()
	d = {}
	d['0/0'] = 0
	x = 0
	y = 0
	res = [0, n + 1]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		k = str(x) + '/' + str(y)
		if k not in d:
			d[k] = i + 1
		else:
			if i + 1 - d[k] < res[1] - res[0]:
				res = [d[k] + 1, i + 1]
			d[k] = i + 1
	if res[1] == n + 1:
		print(-1)
	else:
		print(*res)


import math
import sys
from collections import defaultdict, Counter, deque, OrderedDict
import bisect
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda : map(int, input().split())
alele = lambda : list(map(int, input().split()))

def list2d(a, b, c):
	return [[c] * b for i in range(a)]
from itertools import accumulate, groupby
import sys
mod = 1000000007
for _ in range(int(input())):
	N = int(input())
	S = input()
	mark = {}
	Ans = -1
	mark[0, 0] = 0
	x = 0
	y = 0
	mini = 1000000000.0
	for i in range(N):
		if S[i] == 'L':
			x -= 1
			if i != 0 and S[i - 1] == 'R':
				Ans = (i, i + 1)
				break
		elif S[i] == 'R':
			x += 1
			if i != 0 and S[i - 1] == 'L':
				Ans = (i, i + 1)
				break
		elif S[i] == 'U':
			y += 1
			if i != 0 and S[i - 1] == 'D':
				Ans = (i, i + 1)
				break
		elif S[i] == 'D':
			y -= 1
			if i != 0 and S[i - 1] == 'U':
				Ans = (i, i + 1)
				break
		z = mark.get((x, y), -1)
		if z == -1:
			mark[x, y] = i + 1
		else:
			r = i - z
			if r < mini:
				mini = r
				Ans = (z + 1, i + 1)
			mark[x, y] = i + 1
	if Ans == -1:
		print(-1)
	else:
		print(*Ans)


import sys
input = sys.stdin.readline
t = int(input())
to_dire = {'L': (-1, 0), 'R': (+1, 0), 'U': (0, +1), 'D': (0, -1)}
for _ in range(t):
	n = int(input())
	s = input()
	memo = {(0, 0): 0}
	pos = (0, 0)
	ans_width = 10 ** 9
	ans = None
	for (i, char) in enumerate(s[:-1]):
		pos = (pos[0] + to_dire[char][0], pos[1] + to_dire[char][1])
		if pos not in memo:
			memo[pos] = i + 1
		else:
			if ans_width > i + 1 - (memo[pos] + 1):
				ans_width = i + 1 - (memo[pos] + 1)
				ans = (memo[pos] + 1, i + 1)
			memo[pos] = i + 1
	if ans is not None:
		print(*ans)
	else:
		print(-1)


from collections import Counter
t = int(input())
inf = 10 ** 18
for _ in range(t):
	n = int(input())
	s = input()
	ans = [inf, 0, 0]
	cnt = Counter({(0, 0): 1})
	(x, y) = (0, 0)
	for (i, c) in enumerate(s, start=1):
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y -= 1
		else:
			y += 1
		if (x, y) in cnt and i - cnt[x, y] < ans[0]:
			ans[0] = i - cnt[x, y]
			(ans[1], ans[2]) = (cnt[x, y], i)
		cnt[x, y] = i + 1
	if ans[0] < inf:
		print(ans[1], ans[2])
	else:
		print(-1)


t = int(input())
for i in range(t):
	n = int(input())
	a = input()
	pos = dict()
	curr = [0, 0]
	minimum = n + 1
	ans = [-1, -1]
	pos[0, 0] = -1
	for j in range(len(a)):
		if a[j:j + 1] == 'U':
			curr[1] += 1
		elif a[j:j + 1] == 'D':
			curr[1] -= 1
		elif a[j:j + 1] == 'L':
			curr[0] -= 1
		else:
			curr[0] += 1
		current = (curr[0], curr[1])
		if current in pos:
			if j - pos[current] < minimum:
				minimum = j - pos[current]
				ans = [pos[current], j]
		pos[current] = j
	if minimum == n + 1:
		print(-1)
	else:
		print(ans[0] + 2, ans[1] + 1)


t = int(input())
for test in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	dic = {}
	dic[0, 0] = [-1]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in dic:
			dic[x, y].append(i)
		else:
			dic[x, y] = [i]
	ans = 10 ** 9 + 7
	res = ''
	for i in dic:
		ae = dic[i]
		if len(ae) >= 2:
			for i in range(len(ae) - 1):
				temp = ae[i + 1] - ae[i]
				if temp < ans:
					res = str(ae[i] + 2) + ' ' + str(ae[i + 1] + 1)
					ans = temp
	if ans == 10 ** 9 + 7:
		print(-1)
	else:
		print(res)


from sys import stdin, stdout

class Solve:

	def __init__(self):
		R = stdin.readline
		W = stdout.write
		ans = []
		for t in range(int(input())):
			n = int(input())
			s = R()
			check = {'0_0': 0}
			d = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
			x = y = l = r = 0
			dis = 1000000000
			for i in range(n):
				x += d[s[i]][0]
				y += d[s[i]][1]
				tmps = str(x) + '_' + str(y)
				if tmps not in check:
					check[tmps] = i + 1
				else:
					if i + 1 - check[tmps] < dis:
						(l, r) = (check[tmps] + 1, i + 1)
						dis = i + 1 - check[tmps]
					check[tmps] = i + 1
			if l and r:
				ans.append(str(l) + ' ' + str(r) + '\n')
			else:
				ans.append('-1\n')
		W(''.join(ans))

def main():
	s = Solve()
main()


mod = 10 ** 9 + 7
import math
from bisect import bisect_left
from collections import Counter
from itertools import combinations

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

def fain():
	return map(float, input().split())
for _ in range(int(input())):
	n = int(input())
	s = input()
	i = 0
	j = 0
	vis = {}
	done = False
	vis[i, j] = 0
	ans = []
	for i1 in range(1, n + 1):
		x = s[i1 - 1]
		if x == 'L':
			i -= 1
		elif x == 'R':
			i += 1
		elif x == 'U':
			j += 1
		else:
			j -= 1
		if (i, j) in vis.keys():
			newans = [vis[i, j] + 1, i1]
			if len(ans) == 0 or newans[1] - newans[0] < ans[1] - ans[0]:
				ans = newans
				done = True
		vis[i, j] = i1
	if not done:
		print(-1)
	else:
		print(ans[0], ans[1])


N = int(input())
for _ in range(N):
	n = int(input())
	s = input()
	pos = [0, 0]
	was = {}
	was[0, 0] = 0
	found = False
	ans = []
	for i in range(n):
		v = s[i]
		if v == 'U':
			pos[1] += 1
		if v == 'D':
			pos[1] -= 1
		if v == 'R':
			pos[0] += 1
		if v == 'L':
			pos[0] -= 1
		if (pos[0], pos[1]) in was:
			found = True
			ans.append((was[pos[0], pos[1]] + 1, i + 1))
		was[pos[0], pos[1]] = i + 1
	if not found:
		print(-1)
	else:
		ln = 10 ** 9
		ANS = (-1, -1)
		for (a, b) in ans:
			d = abs(a - b) + 1
			if d < ln:
				ln = d
				ANS = (a, b)
		print(*ANS)


import sys
input = sys.stdin.readline
INF = 10 ** 14
Q = int(input())
Query = []
for _ in range(Q):
	N = int(input())
	S = list(input().rstrip())
	Query.append((N, S))
for (N, S) in Query:
	dp1 = {}
	dp1[0] = {0: 0}
	ud1 = 0
	lr1 = 0
	ans = INF
	for (i, s) in enumerate(S):
		if s == 'L':
			lr1 -= 1
		elif s == 'R':
			lr1 += 1
		elif s == 'U':
			ud1 += 1
		else:
			ud1 -= 1
		if lr1 in dp1 and ud1 in dp1[lr1]:
			delta = i + 1 - dp1[lr1][ud1]
			if delta < ans:
				ans = delta
				al = dp1[lr1][ud1] + 1
				ar = i + 1
		if lr1 in dp1:
			dp1[lr1][ud1] = i + 1
		else:
			dp1[lr1] = {ud1: i + 1}
	if ans == INF:
		print(-1)
	else:
		print(al, ar)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(cx, cy) = (0, 0)
	t = 0
	d = defaultdict(dict)
	d[cx][cy] = t
	m = 10 ** 18
	for si in s:
		if si == 'L':
			cx -= 1
		elif si == 'R':
			cx += 1
		elif si == 'U':
			cy += 1
		else:
			cy -= 1
		t += 1
		if cx in d and cy in d[cx]:
			if m > t - d[cx][cy]:
				(ans_l, ans_r) = (d[cx][cy] + 1, t)
				m = t - d[cx][cy]
		d[cx][cy] = t
	if m == 10 ** 18:
		print(-1)
	else:
		print(ans_l, ans_r)


for i in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	ans = int(10000000000.0)
	ansx = ansy = -1
	d = {}
	d[0, 0] = 0
	for k in range(n):
		now = s[k]
		if now == 'L':
			x -= 1
		elif now == 'R':
			x += 1
		elif now == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			temp = d[x, y]
			if k - temp < ans:
				ans = k - temp
				(ansx, ansy) = (temp + 1, k + 1)
		d[x, y] = k + 1
	if ans != 10000000000.0:
		print(ansx, ansy)
	else:
		print(-1)


import sys, itertools, math, collections
T = int(sys.stdin.readline())
D = {'L': [-1, 0], 'R': [1, 0], 'U': [0, -1], 'D': [0, 1]}
for _ in range(T):
	n = int(sys.stdin.readline().strip())
	S = sys.stdin.readline().strip()
	H = {}
	H[0, 0] = 0
	(x, y) = (0, 0)
	(start, end) = (0, len(S) + 1)
	for (i, s) in enumerate(S):
		x += D[s][0]
		y += D[s][1]
		if (x, y) in H:
			d = i + 1 - H[x, y]
			if d < end - start:
				start = H[x, y] + 1
				end = i + 1
		H[x, y] = i + 1
	if end <= len(S):
		print(start, end)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	_ = input()
	s = input()
	dist = {(0, 0): [0]}
	rl = 0
	ud = 0
	for i in range(len(s)):
		if s[i] == 'R':
			rl += 1
		elif s[i] == 'L':
			rl -= 1
		elif s[i] == 'U':
			ud += 1
		else:
			ud -= 1
		if (rl, ud) in dist:
			dist[rl, ud].append(i + 1)
		else:
			dist[rl, ud] = [i + 1]
	ans = 10 ** 10
	anss = (-1, -1)
	for k in dist:
		for i in range(len(dist[k]) - 1):
			if ans > dist[k][i + 1] - dist[k][i] - 1:
				anss = (dist[k][i] + 1, dist[k][i + 1])
				ans = dist[k][i + 1] - dist[k][i] - 1
	if ans == 10 ** 10:
		print(-1)
	else:
		print(*anss)


def result(s, k):
	left = -1
	r = k
	d = {}
	l = (0, 0)
	d[l] = 0
	for i in range(0, len(s)):
		x = l[0]
		y = l[1]
		if s[i] == 'L':
			x = x - 1
		elif s[i] == 'R':
			x = x + 1
		elif s[i] == 'U':
			y = y + 1
		else:
			y = y - 1
		l = (x, y)
		if l in d:
			if i - d[l] + 1 < r - left + 1:
				r = i
				left = d[l]
		d[l] = i + 1
	if left == -1:
		print(-1)
	else:
		print(left + 1, r + 1)
t = int(input())
while t > 0:
	k = int(input())
	s = input()
	result(s, k)
	t = t - 1


from collections import Counter
from collections import defaultdict
import math
import random
import heapq as hq
from math import sqrt
import sys
from functools import reduce

def input():
	return sys.stdin.readline().strip()

def iinput():
	return int(input())

def tinput():
	return input().split()

def rinput():
	return map(int, tinput())

def rlinput():
	return list(rinput())
mod = int(1000000000.0) + 7

def factors(n):
	return set(reduce(list.__add__, ([i, n // i] for i in range(1, int(n ** 0.5) + 1) if n % i == 0)))
for _ in range(iinput()):
	n = iinput()
	s = input()
	ans = 9999999999
	d = {(0, 0): -1}
	curr = [0, 0]
	idx = 0
	fans = [-1, -1]
	for i in s:
		if i == 'L' or i == 'D':
			curr[0 if i == 'L' else 1] += 1
		else:
			curr[0 if i == 'R' else 1] -= 1
		if tuple(curr) in d:
			if idx - d[tuple(curr)] < ans:
				fans = [d[tuple(curr)], idx]
				ans = idx - d[tuple(curr)]
		d[tuple(curr)] = idx
		idx += 1
	fans = [str(fans[0] + 2), str(fans[1] + 1)]
	print(' '.join(fans) if ans != 9999999999 else -1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(l, r) = (0, 999999999999999)
	(x, y) = (0, 0)
	dct = {(0, 0): 1}
	for i in range(len(s)):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if (x, y) in dct.keys():
			if r - l > i + 1 - dct[x, y]:
				(l, r) = (dct[x, y], i + 1)
			dct[x, y] = i + 2
		else:
			dct[x, y] = i + 2
	if l == 0 and r == 999999999999999:
		print(-1)
	else:
		print(l, r)


import math
import re
import itertools
import copy

def input_linear(lamb=lambda x: int(x), seperator=' '):
	return map(lamb, input().split(seperator))

def input_array(lamb=lambda x: int(x), seperator=' '):
	return list(map(lamb, input().split(seperator)))

def input_matrix(rows, lamb=lambda x: int(x), seperator=' '):
	tmp_matrix = []
	for i in range(rows):
		tmp_matrix.append(input_array(lamb, seperator))
	return tmp_matrix

def input_graph_al_pair(vertices, lines, lamb=lambda x: int(x), seperator=' ', directional=False, remove_dup=False):
	temp_matrix = [x[:] for x in [[]] * vertices]
	if not directional:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
				temp_matrix[inb].append(ina)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
				if ina not in temp_matrix[inb]:
					temp_matrix[inb].append(ina)
		return temp_matrix
	else:
		if not remove_dup:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				temp_matrix[ina].append(inb)
		else:
			for i in range(lines):
				(ina, inb) = input_linear(lamb, seperator)
				if inb not in temp_matrix[ina]:
					temp_matrix[ina].append(inb)
		return temp_matrix
for t in range(int(input())):
	n = int(input())
	a = input()
	di = {}
	curr = [0, 0]
	di[0, 0] = [0]
	for i in range(n):
		if a[i] == 'L':
			curr[0] -= 1
		elif a[i] == 'R':
			curr[0] += 1
		elif a[i] == 'U':
			curr[1] += 1
		elif a[i] == 'D':
			curr[1] -= 1
		if tuple(curr) not in di.keys():
			di[tuple(curr)] = [i + 1]
		else:
			di[tuple(curr)].append(i + 1)
	mi = math.inf
	ml = [0, 0]
	for i in di.values():
		i.sort()
		if not len(i) == 1:
			for k in range(1, len(i)):
				if mi > i[k] - i[k - 1]:
					ml = [i[k - 1] + 1, i[k]]
					mi = i[k] - i[k - 1]
	if mi != math.inf:
		print(' '.join(list(map(lambda x: str(x), ml))))
	else:
		print(-1)


t = int(input())

class P:

	def __init__(self, x, y):
		self.x = x
		self.y = y

	def __repr__(self):
		return str((self.x, self.y))

	def __hash__(self):
		return hash((self.x, self.y))
for _ in range(t):
	n = int(input())
	s = input()[:n]
	subs = []
	ps = {(0, 0): 0}
	pos = (0, 0)
	for (i, p) in enumerate(s):
		(x, y) = (pos[0], pos[1])
		if p == 'R':
			pos = (x + 1, y)
		if p == 'L':
			pos = (x - 1, y)
		if p == 'U':
			pos = (x, y + 1)
		if p == 'D':
			pos = (x, y - 1)
		if pos in ps.keys():
			subs.append((ps[pos], i))
		ps[pos] = i + 1
	if len(subs) == 0:
		print(-1)
		continue
	substr = min(subs, key=lambda x: x[1] - x[0] + 1)
	print(substr[0] + 1, substr[1] + 1)


for _ in range(int(input())):
	a = int(input())
	b = input()
	x = y = 0
	amr = {(0, 0): 0}
	l = 0
	r = 1000000
	flag = True
	for i in range(len(b)):
		if b[i] == 'L':
			if (x - 1, y) in amr and r - l > i - amr[x - 1, y]:
				l = amr[x - 1, y]
				r = i
				flag = False
			x -= 1
			amr[x, y] = i + 1
		elif b[i] == 'R':
			if (x + 1, y) in amr and r - l > i - amr[x + 1, y]:
				l = amr[x + 1, y]
				r = i
				flag = False
			x += 1
			amr[x, y] = i + 1
		elif b[i] == 'U':
			if (x, y + 1) in amr and r - l > i - amr[x, y + 1]:
				l = amr[x, y + 1]
				r = i
				flag = False
			y += 1
			amr[x, y] = i + 1
		else:
			if (x, y - 1) in amr and r - l > i - amr[x, y - 1]:
				l = amr[x, y - 1]
				r = i
				flag = False
			y -= 1
			amr[x, y] = i + 1
	if flag == False:
		print(l + 1, r + 1)
	else:
		print(-1)


from collections import defaultdict as dc

def solv():
	l = int(input())
	s = input()
	x = 0
	y = 0
	vis = {}
	res = 10 ** 9
	stx = 0
	sty = 0
	vis[0, 0] = 1
	for p in range(l):
		n = s[p]
		if n == 'L':
			x -= 1
		elif n == 'R':
			x += 1
		elif n == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in vis:
			j = vis[x, y]
			k = p + 1
			if k - j < res:
				res = k - j
				stx = j
				sty = k
		vis[x, y] = p + 2
	if res == 10 ** 9:
		print(-1)
		return
	print(stx, sty)
for n in range(int(input())):
	solv()


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	prefix = {(0, 0): 0}
	dirs = {'L': (0, -1), 'R': (0, 1), 'U': (-1, 0), 'D': (1, 0)}
	(r, c) = (0, 0)
	res = (1, 10000000000)
	found = False
	for i in range(n):
		(r, c) = (r + dirs[s[i]][0], c + dirs[s[i]][1])
		if (r, c) in prefix:
			if res[1] - res[0] > i - prefix[r, c]:
				found = True
				res = (prefix[r, c] + 1, i + 1)
		prefix[r, c] = i + 1
	if found:
		print(res[0], res[1])
	else:
		print(-1)


import math
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	dic = {}
	ct = 0
	val = math.inf
	ansx = None
	ansy = None
	dic[0, 0] = ct
	for c in s:
		ct += 1
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in dic.keys():
			if val > ct - dic[x, y]:
				ansx = dic[x, y]
				ansy = ct
			val = min(val, ct - dic[x, y])
		dic[x, y] = ct
	if val != math.inf:
		print(ansx + 1, ansy)
	else:
		print(-1)


t = int(input())
while t != 0:
	n = int(input())
	s = input()
	pos = [0, 0]
	mydict = {(0, 0): 0}
	min_dis = 10000000
	i1 = -10000
	i2 = -10000
	for i in range(1, n + 1):
		if s[i - 1] == 'L':
			pos[0] -= 1
		elif s[i - 1] == 'R':
			pos[0] += 1
		elif s[i - 1] == 'U':
			pos[1] += 1
		elif s[i - 1] == 'D':
			pos[1] -= 1
		if (pos[0], pos[1]) in mydict:
			dis = i - mydict[pos[0], pos[1]] - 1
			if min_dis > dis:
				min_dis = dis
				i1 = mydict[pos[0], pos[1]] + 1
				i2 = i
		mydict[pos[0], pos[1]] = i
	if min_dis == 10000000:
		print(-1)
	else:
		print(i1, i2)
	t -= 1


T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	l = -1
	r = n
	visited = {}
	cur = (0, 0)
	visited[cur] = 0
	for i in range(n):
		c = s[i]
		if c == 'L':
			cur = (cur[0] - 1, cur[1])
		elif c == 'R':
			cur = (cur[0] + 1, cur[1])
		elif c == 'U':
			cur = (cur[0], cur[1] + 1)
		elif c == 'D':
			cur = (cur[0], cur[1] - 1)
		if cur in visited:
			cycle_length = i - visited[cur] + 1
			if cycle_length < r - l + 1:
				l = visited[cur]
				r = i
		visited[cur] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


t = int(input())
while t:
	n = int(input())
	s = input()
	MAP = {}
	MAP[0, 0] = 0
	pos = [0, 0]
	st = -1
	dr = n
	for i in range(n):
		if s[i] == 'L':
			pos[0] -= 1
		elif s[i] == 'R':
			pos[0] += 1
		elif s[i] == 'U':
			pos[1] += 1
		else:
			pos[1] -= 1
		if (pos[0], pos[1]) in MAP.keys():
			if i - MAP[pos[0], pos[1]] + 1 <= dr - st + 1:
				st = MAP[pos[0], pos[1]]
				dr = i
		MAP[pos[0], pos[1]] = i + 1
	if st == -1:
		print(-1)
	else:
		print(str(st + 1) + ' ' + str(dr + 1))
	t -= 1


q = int(input())
for _ in range(q):
	n = int(input())
	s = input()
	dat = dict()
	(x, y, t) = (0, 0, 0)
	dat[x * 200000 + y] = 0
	(l, r, d) = (-1, -1, 99999999999)
	for i in range(n):
		t += 1
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if x * 200000 + y in dat:
			cd = i - dat[x * 200000 + y]
			if cd < d:
				l = dat[x * 200000 + y]
				r = t
				d = cd
		dat[x * 200000 + y] = t
	if l == -1:
		print(-1)
	else:
		print('{0} {1}'.format(l + 1, r))


x = {'L': -1, 'R': 1, 'U': 0, 'D': 0}
y = {'L': 0, 'R': 0, 'U': 1, 'D': -1}

def solve(s):
	d = {(0, 0): [0]}
	xx = yy = 0
	for (i, ss) in enumerate(s):
		xx += x[ss]
		yy += y[ss]
		if (xx, yy) in d:
			d[xx, yy].append(i + 1)
		else:
			d[xx, yy] = [i + 1]
	best = 10000000000.0
	(best_from, best_to) = (0, 0)
	for k in d:
		if len(d[k]) >= 2:
			for i in range(1, len(d[k])):
				if d[k][i] - d[k][i - 1] < best:
					best = d[k][i] - d[k][i - 1]
					best_from = d[k][i - 1] + 1
					best_to = d[k][i]
	if best == 10000000000.0:
		return -1
	return f'{best_from} {best_to}'

def main():
	t = int(input())
	for _ in range(t):
		_ = int(input())
		s = input().strip()
		print(solve(s))
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	x = 0
	y = 0
	d[0, 0] = [0]
	prelast = -1
	last = -1
	c = 0
	for j in range(n):
		c = c + 1
		i = s[j]
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		try:
			d[x, y].append(c)
			if last == -1:
				last = d[x, y][-1]
				prelast = d[x, y][-2]
			if d[x, y][-1] - d[x, y][-2] < last - prelast:
				last = d[x, y][-1]
				prelast = d[x, y][-2]
		except:
			d[x, y] = [c]
	if prelast != -1:
		print(str(prelast + 1) + ' ' + str(last))
	else:
		print(-1)


tests = int(input())
for k in range(tests):
	n = int(input())
	s = input()
	x = y = 0
	d = {(x, y): 0}
	flag = 0
	mini = 2147483647
	ans = [0, 0]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in d:
			l = d[x, y] + 1
			r = i + 1
			if r - l < mini:
				mini = r - l
				ans = [l, r]
		d[x, y] = i + 1
	if sum(ans) == 0:
		print(-1)
	else:
		print(ans[0], ans[1])


def solve(n, a):
	mp = {0: 0}
	(s, x, y, ans) = (0, 0, 0, 200000.0 + 1)
	for (i, v) in enumerate(a):
		s += v
		if s not in mp:
			mp[s] = i + 1
		else:
			j = mp[s]
			mp[s] = i + 1
			if ans > i + 1 - j:
				ans = i + 1 - j
				(x, y) = (j + 1, i + 1)
	if (x, y) == (0, 0):
		print(-1)
	else:
		print(x, y)

def main():
	tc = int(input())
	mp = {'L': 1, 'R': -1, 'U': 1000000000.0, 'D': -1000000000.0}
	for _ in range(tc):
		n = int(input())
		a = [mp[x] for x in input()]
		solve(n, a)
main()


from sys import stdin

def inp():
	return (ss.rstrip() for ss in stdin).__next__()

def itg():
	return int(inp())

def mpint():
	return map(int, inp().split())
INF = int(1000000000.0)
for case in range(itg()):
	size = itg()
	s = inp()
	pos = (0, 0)
	d = {pos: 0}
	ans = ()
	distance = INF
	for i in range(1, size + 1):
		c = s[i - 1]
		if c == 'L':
			pos = (pos[0] - 1, pos[1])
		elif c == 'R':
			pos = (pos[0] + 1, pos[1])
		elif c == 'U':
			pos = (pos[0], pos[1] + 1)
		elif c == 'D':
			pos = (pos[0], pos[1] - 1)
		if pos in d and i - (d[pos] + 1) < distance:
			ans = (d[pos] + 1, i)
			distance = i - (d[pos] + 1)
		d[pos] = i
	if ans:
		print(*ans)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	x = y = 0
	cm = 1000000
	res = [-1]
	d = {'0_0': 1}
	for (index, c) in enumerate(s):
		if c == 'U':
			y += 1
		elif c == 'R':
			x += 1
		elif c == 'D':
			y -= 1
		elif c == 'L':
			x -= 1
		end = str(x) + '_' + str(y)
		if end in d:
			if index + 1 - d[end] < cm:
				cm = index + 1 - d[end]
				res = (d[end], index + 1)
		d[end] = index + 2
	print(*res)


def one():
	return int(input())

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

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

def st():
	return input()
for i in range(one()):
	input()
	d = {(0, 0): 0}
	s = st()
	c = [0, 0]
	r = 0
	m = float('inf')
	ans = None
	for j in s:
		if j == 'U':
			c[1] += 1
		if j == 'D':
			c[1] -= 1
		if j == 'R':
			c[0] += 1
		if j == 'L':
			c[0] -= 1
		r += 1
		if (c[0], c[1]) in d:
			if m > r - d[c[0], c[1]] + 1:
				ans = (d[c[0], c[1]] + 1, r)
				m = r - d[c[0], c[1]] + 1
			d[c[0], c[1]] = r
		else:
			d[c[0], c[1]] = r
	if not ans:
		print(-1)
	else:
		print(*ans)


t = int(input())
for i in range(t):
	n = int(input())
	b = input()
	x = 0
	y = 0
	h = dict()
	h[0, 0] = -1
	m = 100000000
	f = 0
	for j in range(len(b)):
		if b[j] == 'L':
			x += -1
		elif b[j] == 'R':
			x += 1
		elif b[j] == 'U':
			y += 1
		else:
			y += -1
		if (x, y) in h.keys():
			f = 1
			p = j - h[x, y]
			if p < m:
				m = p
				l = h[x, y] + 2
				u = j + 1
			h[x, y] = j
		else:
			h[x, y] = j
	if f == 0:
		print(-1)
	else:
		print(l, u)


for t in range(int(input())):
	n = int(input())
	s = list(input())
	x = 0
	y = 0
	pos = {}
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		pos[str(x) + '/' + str(y)] = -1
	pos['0/0'] = 0
	g = h = -1
	x = y = 0
	minlen = 10 ** 9
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		val = pos[str(x) + '/' + str(y)]
		if val != -1 and i - val < minlen:
			minlen = i - val
			g = val + 1
			h = i + 1
		pos[str(x) + '/' + str(y)] = i + 1
	if g == -1 and h == -1:
		print(-1)
	else:
		print(g, h)


def Move(x, y, s):
	if s == 'U':
		y += 1
	elif s == 'L':
		x -= 1
	elif s == 'R':
		x += 1
	else:
		y -= 1
	return (x, y)
t = int(input())
for i in range(t):
	n = int(input())
	l = input()
	x = 0
	y = 0
	out = []
	dct = dict([('0 0', 0)])
	for j in range(n):
		(x, y) = Move(x, y, l[j])
		s = str(x) + ' ' + str(y)
		if dct.get(s) == None:
			dct.update([(s, j + 1)])
		else:
			out.append([dct.get(s), j + 1])
			dct.update([(s, j + 1)])
	if len(out) == 0:
		print(-1)
	else:
		mn = out[0]
		for n in range(1, len(out)):
			if mn[1] - mn[0] > out[n][1] - out[n][0]:
				mn = out[n]
		print(mn[0] + 1, mn[1])


t = int(input())
while t:
	n = int(input())
	s = input()
	ls = [[0, 0, i] for i in range(n + 1)]
	for i in range(n):
		if s[i] == 'L':
			ls[i + 1][0] = ls[i][0] - 1
			ls[i + 1][1] = ls[i][1]
		elif s[i] == 'R':
			ls[i + 1][0] = ls[i][0] + 1
			ls[i + 1][1] = ls[i][1]
		elif s[i] == 'U':
			ls[i + 1][0] = ls[i][0]
			ls[i + 1][1] = ls[i][1] + 1
		else:
			ls[i + 1][0] = ls[i][0]
			ls[i + 1][1] = ls[i][1] - 1
	ls.sort()
	flag = False
	j = 0
	k = n + 1
	for i in range(1, n + 1):
		if ls[i][0] == ls[i - 1][0] and ls[i][1] == ls[i - 1][1]:
			if ls[i][2] - ls[i - 1][2] < k - j:
				j = ls[i - 1][2] + 1
				k = ls[i][2]
				flag = True
	if flag == False:
		print(-1)
	else:
		print(j, k)
	t -= 1


from sys import stdin, stdout
t = 1
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	dct = {}
	(dx, dy) = (0, 0)
	dct[0, 0] = 0
	mini = n + 5
	ans = []
	for i in range(n):
		if s[i] == 'L':
			dx -= 1
		elif s[i] == 'R':
			dx += 1
		elif s[i] == 'U':
			dy += 1
		else:
			dy -= 1
		if (dx, dy) in dct:
			if i - dct[dx, dy] < mini:
				mini = i - dct[dx, dy]
				ans = [dct[dx, dy] + 1, i + 1]
		dct[dx, dy] = i + 1
	if len(ans) > 0:
		print(ans[0], ans[1])
	else:
		print('-1')


t = int(input())
for x in range(t):
	s = input()
	s = input()
	l = []
	for i in range(len(s)):
		if s[i] == 'L':
			l.append(1)
		elif s[i] == 'R':
			l.append(-1)
		elif s[i] == 'U':
			l.append(100000000.0)
		else:
			l.append(-100000000.0)
	d = {0: -1}
	dp = [0 for i in range(len(l))]
	dp[0] = l[0]
	minlen = 100000000.0
	for i in range(1, len(l)):
		dp[i] = dp[i - 1] + l[i]
	for i in range(len(l)):
		if dp[i] not in d:
			d[dp[i]] = i
		else:
			if i - d[dp[i]] < minlen:
				minlen = i - d[dp[i]]
				start = d[dp[i]] + 2
				end = i + 1
			d[dp[i]] = i
	if minlen == 100000000.0:
		print(-1)
	else:
		print(start, end)


import atexit
import io
import sys
_INPUT_LINES = sys.stdin.read().splitlines()
input = iter(_INPUT_LINES).__next__
_OUTPUT_BUFFER = io.StringIO()
sys.stdout = _OUTPUT_BUFFER

@atexit.register
def write():
	sys.__stdout__.write(_OUTPUT_BUFFER.getvalue())
for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	seen = {(0, 0): [0]}
	ans = []
	for (i, c) in enumerate(s):
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		if (x, y) in seen:
			a = (max(seen[x, y]) + 1, i + 1)
			ans.append(a)
			if a[1] - a[0] == 1:
				break
			seen[x, y].append(i + 1)
		else:
			seen[x, y] = [i + 1]
	if ans:
		best = n + 1
		p = None
		for a in ans:
			dist = a[1] - a[0]
			if dist < best:
				best = dist
				p = a
		print(p[0], p[1])
	else:
		print('-1')


for _ in range(int(input())):
	n = int(input())
	s = input()
	v = 0
	d = {0: [0]}
	(e, f) = (0, 2000000.0)
	flag = 0
	for i in range(n):
		x = s[i]
		if x == 'U':
			v += 1j
		if x == 'R':
			v += 1
		if x == 'D':
			v -= 1j
		if x == 'L':
			v -= 1
		d[v] = d.get(v, [])
		d[v].append(i + 1)
		a = d[v]
		if len(a) > 1:
			if a[-1] - a[-2] < f - e:
				flag = 1
				e = a[-2]
				f = a[-1]
	print(str(e + 1) + ' ' + str(f) if flag else -1)


for i in range(int(input())):
	n = int(input())
	a = input()
	b = (0, 0)
	c = {}
	c[b] = 0
	q = -1
	w = -1
	for item in range(len(a)):
		if a[item] == 'L':
			b = (b[0] - 1, b[1])
		elif a[item] == 'R':
			b = (b[0] + 1, b[1])
		elif a[item] == 'U':
			b = (b[0], b[1] + 1)
		else:
			b = (b[0], b[1] - 1)
		try:
			d = c[b]
			c[b] = item + 1
			if q > -1:
				if item - d < w - q:
					q = d + 1
					w = item + 1
			else:
				q = d + 1
				w = item + 1
			if w - q == 1:
				break
		except KeyError:
			c[b] = item + 1
	if q > -1:
		print(q, w)
	else:
		print(-1)


from sys import stdin, stdout
from collections import defaultdict
t = int(input())
answers = []
for _ in range(t):
	n = int(input())
	s = stdin.readline().strip()
	start = (0, 0)
	(ans, minlen) = (10 ** 9, 10 ** 9)
	d = defaultdict(list)
	d[start] = [0]
	for (i, mov) in enumerate(s):
		if mov == 'L':
			new = (start[0] - 1, start[1])
		elif mov == 'R':
			new = (start[0] + 1, start[1])
		elif mov == 'U':
			new = (start[0], start[1] + 1)
		else:
			new = (start[0], start[1] - 1)
		if len(d[new]):
			prev = d[new][-1]
			if i - prev + 1 < minlen:
				minlen = i - prev + 1
				ans = (prev + 1, i + 1)
			else:
				pass
		d[new].append(i + 1)
		start = new
	answers.append(ans if ans != 10 ** 9 else -1)
for ans in answers:
	if ans == -1:
		print(ans)
	else:
		print(*ans)


def solve(s, n):
	dec = {'0|0': -1}
	i = 0
	j = 0
	ans = [0, 10 ** 10]
	for k in range(n):
		if s[k] == 'U':
			i += 1
		elif s[k] == 'D':
			i -= 1
		elif s[k] == 'L':
			j += 1
		elif s[k] == 'R':
			j -= 1
		key1 = '{}|{}'.format(i, j)
		if key1 in dec:
			if k - dec[key1] - 1 <= ans[1] - ans[0]:
				ans = [dec[key1] + 1, k]
		dec[key1] = k
	return ans
for _ in range(int(input())):
	n = int(input())
	s = input()
	p = solve(s, n)
	p[0] += 1
	p[1] += 1
	if p[1] == 10 ** 10 + 1:
		print(-1)
	else:
		print(*p)


import sys, math

def input():
	return sys.stdin.readline()[:-1]

def main():
	q = int(input())
	for _ in range(q):
		n = int(input())
		s = input()
		(x, y) = (0, 0)
		t = 0
		p = [[0, 0, 0]]
		for k in range(n):
			if s[k] == 'U':
				y += 1
			elif s[k] == 'D':
				y -= 1
			elif s[k] == 'L':
				x -= 1
			else:
				x += 1
			p.append([x, y, k + 1])
		p = sorted(p)
		(l, r) = (-1, n + 1)
		for k in range(n):
			if p[k][0] == p[k + 1][0] and p[k][1] == p[k + 1][1]:
				if p[k + 1][2] - p[k][2] < r - l:
					(l, r) = (p[k][2] + 1, p[k + 1][2])
			if r - l == 1:
				break
		if l == -1:
			print(-1)
		else:
			print(l, r)
main()


d = {'L': [-1, 0], 'R': [1, 0], 'U': [0, 1], 'D': [0, -1]}
for _ in range(int(input())):
	n = int(input())
	s = input()
	s = 'M' + s
	d1 = {(0, 0): 0}
	(x, y) = (0, 0)
	ans = float('inf')
	for i in range(1, n + 1):
		x = x + d[s[i]][0]
		y = y + d[s[i]][1]
		if (x, y) in d1:
			p = d1[x, y]
			if i - p < ans:
				ans1 = p + 1
				ans2 = i
				ans = i - p
			d1[x, y] = i
		else:
			d1[x, y] = d1.get((x, y), i)
	if ans == float('inf'):
		print(-1)
	else:
		print(ans1, ans2)


tc = int(input())
for _ in range(tc):
	n = int(input())
	s = input()
	d = {(0, 0): [0]}
	m = float('inf')
	pt = [0, 0]
	for (j, i) in enumerate(s):
		if i == 'L':
			pt[0] -= 1
		elif i == 'R':
			pt[0] += 1
		elif i == 'U':
			pt[1] += 1
		elif i == 'D':
			pt[1] -= 1
		d.setdefault((pt[0], pt[1]), []).append(j + 1)
	ans = None
	for i in d:
		if len(d[i]) >= 2:
			t1 = d[i]
			for j in range(1, len(t1)):
				if t1[j] - t1[j - 1] + 1 < m:
					m = t1[j] - t1[j - 1]
					ans = [t1[j - 1] + 1, t1[j]]
	if ans:
		if ans[0] == 0:
			print(ans[0], ans[1])
		else:
			print(ans[0], ans[1])
	else:
		print(-1)


for t in range(int(input())):
	n = int(input())
	s = list(input())
	r = 0
	c = 0
	r1 = 300000 - n - 1
	c1 = 300000
	Dict = {}
	Dict[0, 0] = 0
	for i in range(0, n):
		if s[i] == 'L':
			r -= 1
		elif s[i] == 'R':
			r += 1
		elif s[i] == 'U':
			c += 1
		else:
			c -= 1
		if Dict.get((r, c), -1) != -1:
			k = Dict[r, c]
			if i + 1 - k < c1 - r1:
				r1 = k + 1
				c1 = i + 1
		Dict[r, c] = i + 1
	if c1 == 300000:
		print('-1')
	else:
		print(r1, end=' ')
		print(c1)


import sys, math, itertools
from collections import Counter, deque, defaultdict
from bisect import bisect_left, bisect_right
from heapq import heappop, heappush, heapify
mod = 10 ** 9 + 7
INF = float('inf')

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

def inpl():
	return list(map(int, sys.stdin.readline().split()))
for _ in range(inp()):
	n = inp()
	s = sys.stdin.readline()
	s = s[:n]
	d = defaultdict(lambda : -1)
	(nx, ny) = (0, 0)
	d[nx, ny] = 0
	mi = INF
	(l, r) = (-1, -1)
	for (i, x) in enumerate(s):
		if x == 'L':
			nx -= 1
		elif x == 'R':
			nx += 1
		elif x == 'U':
			ny += 1
		else:
			ny -= 1
		las = d[nx, ny]
		if las != -1 and i + 1 - las < mi:
			mi = i + 1 - las
			(l, r) = (las + 1, i + 1)
		d[nx, ny] = i + 1
	if mi == INF:
		print(-1)
	else:
		print(l, r)


for _ in range(int(input())):
	n = int(input())
	a = input()
	d = n + 10
	l = r = -1
	di = {(0, 0): 0}
	c = [0, 0]
	for i in range(n):
		c = list(c)
		c[1] = c[1] + 1 if a[i] == 'U' else c[1] - 1 if a[i] == 'D' else c[1]
		c[0] = c[0] + 1 if a[i] == 'R' else c[0] - 1 if a[i] == 'L' else c[0]
		c = tuple(c)
		if di.get(c, -1) != -1:
			if i + 1 - di[c] < d:
				l = di[c]
				di[c] = r = i + 1
				d = i + 1 - l
		di[c] = i + 1
	if l == -1:
		print(r)
	else:
		print(l + 1, r)


from collections import defaultdict

def find_same_ends(path):
	start = [0, 0]
	history = defaultdict(lambda : [])
	history[tuple(start)].append(0)
	for (index, x) in enumerate(path):
		if x == 'L':
			start[0] -= 1
		elif x == 'R':
			start[0] += 1
		elif x == 'U':
			start[1] += 1
		else:
			start[1] -= 1
		history[tuple(start)].append(index + 1)
	return history
t = int(input())
for _ in range(t):
	input()
	path = input().strip()
	hist = find_same_ends(path)
	smallest_diff = float('inf')
	best = None
	for (_, x) in hist.items():
		if len(x) > 1:
			for i in range(len(x) - 1):
				diff = x[i + 1] - x[i]
				if diff < smallest_diff:
					smallest_diff = diff
					best = [x[i] + 1, x[i + 1]]
	if best:
		print(*best)
	else:
		print(-1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	curr = (0, 0)
	last_seen = {}
	best_l = -10000000
	best_r = 10000000
	last_seen[curr] = 0
	for (i, c) in enumerate(s):
		if c == 'L':
			curr = (curr[0] - 1, curr[1])
		elif c == 'R':
			curr = (curr[0] + 1, curr[1])
		elif c == 'U':
			curr = (curr[0], curr[1] + 1)
		elif c == 'D':
			curr = (curr[0], curr[1] - 1)
		l = last_seen.get(curr, -10000000000)
		r = i + 1
		last_seen[curr] = r
		if r - l < best_r - best_l:
			best_l = l
			best_r = r
	if best_l == -10000000 and best_r == 10000000:
		print('-1')
	else:
		print(best_l + 1, best_r)


def f(x, y):
	return str(x) + '.' + str(y)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	d = {}
	ans = [0, 10000000000]
	x = y = 0
	d[f(x, y)] = 0
	chng = False
	for i in range(n):
		if s[i] == 'U':
			y += 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'D':
			y -= 1
		if s[i] == 'L':
			x -= 1
		if d.get(f(x, y), -1) == -1:
			d[f(x, y)] = i + 1
		else:
			pred = d[f(x, y)]
			act = i + 1
			if act - pred + 1 < ans[1] - ans[0] + 1:
				ans = [pred + 1, act]
				chng = True
			d[f(x, y)] = act
	if chng:
		print(ans[0], ans[1])
	else:
		print(-1)


from sys import maxsize
for _ in range(int(input())):
	n = int(input())
	path = str(input())
	(x, y) = (0, 0)
	dic = dict()
	dic[0, 0] = 0
	(a_i, a_j) = (-1, -1)
	minn = maxsize
	for i in range(n):
		if path[i] == 'L':
			x -= 1
		elif path[i] == 'R':
			x += 1
		elif path[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in dic:
			t = i - dic[x, y] + 1
			if t < minn:
				minn = t
				a_i = dic[x, y] + 1
				a_j = i + 1
		dic[x, y] = i + 1
	if a_i == -1:
		print(-1)
	else:
		print(a_i, a_j)


t = int(input())
while t > 0:
	n = int(input())
	s = input()
	x = 0
	y = 0
	mem = {(0, 0): 0}
	r = n
	l = -1
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		key = (x, y)
		if key in mem.keys():
			diff = i - mem[key] + 1
			if diff < r - l + 1:
				l = mem[key]
				r = i
		mem[key] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)
	t -= 1


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	d = {(0, 0): 0}
	m = 10000000000
	(c1, c2) = (0, 0)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if (x, y) in d:
			a = d[x, y]
			b = i + 1
			if b - a < m:
				m = b - a
				(c1, c2) = (a + 1, b)
			d[x, y] = i + 1
		else:
			d[x, y] = i + 1
	if m == 10000000000:
		print(-1)
	else:
		print(c1, c2)


t = int(input())
deslocation = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}
for i in range(t):
	init_position = (0, 0)
	n = int(input())
	sequence = str(input())
	path = {init_position: 0}
	position = 0
	optmization = (len(sequence) + 10, 0)
	for move in sequence:
		new_position = (init_position[0] + deslocation[move][0], init_position[1] + deslocation[move][1])
		if not path.get(new_position) is None:
			if abs(optmization[0] - optmization[1]) > abs(path[init_position] - path[new_position]):
				optmization = (path[new_position], path[init_position])
				path[new_position] = position
		init_position = new_position
		path[new_position] = position + 1
		position += 1
	if optmization == (len(sequence) + 10, 0):
		print(-1)
	else:
		print(min(optmization) + 1, max(optmization) + 1)


import math
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())
for _ in range(inp()):
	n = inp()
	s = insr()
	coord = {(0, 0): 0}
	left = 0
	up = 0
	maxer = 999999999999999
	coords = None
	for i in range(n):
		if s[i] == 'L':
			left -= 1
		elif s[i] == 'R':
			left += 1
		elif s[i] == 'U':
			up += 1
		else:
			up -= 1
		if (left, up) in coord:
			if i + 1 - coord[left, up] < maxer:
				maxer = i + 1 - coord[left, up]
				coords = (coord[left, up], i + 1)
		coord[left, up] = i + 1
	if maxer == 999999999999999:
		print(-1)
	else:
		print(coords[0] + 1, coords[1])


from collections import defaultdict
t = int(input().strip())
dir_dict = {'L': (-1, 0), 'R': (1, 0), 'D': (0, -1), 'U': (0, 1)}
for _ in range(t):
	n = int(input().strip())
	s = input().strip()
	path = defaultdict(int)
	path[0, 0] = 0
	ans = (1, 200010)
	pos = (0, 0)
	for (cur, i) in enumerate(s, 1):
		pos = (pos[0] + dir_dict[i][0], pos[1] + dir_dict[i][1])
		if pos not in path:
			path[pos] = cur
		else:
			cur_len = cur - path[pos]
			if cur_len < ans[1] - ans[0]:
				ans = (path[pos] + 1, cur)
			path[pos] = cur
	if ans[1] - ans[0] >= 200005:
		print(-1)
	else:
		print(ans[0], ans[1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	dic = {(0, 0): 0}
	(x, y, min_l) = (0, 0, [-1, -1, float('inf')])
	for (i, el) in enumerate(s):
		if el == 'L':
			x -= 1
		elif el == 'R':
			x += 1
		elif el == 'U':
			y += 1
		else:
			y -= 1
		try:
			t = dic[x, y]
			if min_l[2] > i + 1 - t:
				(min_l[0], min_l[1], min_l[2]) = (t + 1, i + 1, i - t)
			dic[x, y] = i + 1
		except:
			dic[x, y] = i + 1
	if min_l[0] != -1:
		print(*min_l[:2])
	else:
		print(-1)


import atexit
import io
import sys
_IB = sys.stdin.read().splitlines()
input = iter(_IB).__next__
_OB = io.StringIO()
sys.stdout = _OB

@atexit.register
def write():
	sys.__stdout__.write(_OB.getvalue())

class inp:

	@staticmethod
	def int():
		return int(input())

	@staticmethod
	def ilist():
		return list(map(int, input().split()))

	@staticmethod
	def list():
		return input().split()

	@staticmethod
	def itup():
		return map(int, input().split())

	@staticmethod
	def str():
		return list(input())

def main():
	t = inp.int()
	for _ in range(t):
		n = inp.int()
		s = input()
		poslist = {}
		pos = [0, 0]
		mini = 2 * 10 ** 5 + 1
		left = -100
		right = -100
		for (i, si) in enumerate(s):
			poslist[tuple(pos)] = i
			if si == 'L':
				pos[0] -= 1
			elif si == 'R':
				pos[0] += 1
			elif si == 'U':
				pos[1] += 1
			else:
				pos[1] -= 1
			if tuple(pos) in poslist:
				x = i - poslist[tuple(pos)]
				if x < mini:
					mini = x
					right = i
					left = poslist[tuple(pos)]
		if left == -100 and right == -100:
			print(-1)
		else:
			print(left + 1, right + 1)
main()


t = int(input())
while t:
	t -= 1
	n = int(input())
	m = list(input().strip())
	x = 0
	y = 0
	vis = {}
	done = False
	ans = []
	for i in range(n):
		vis[x, y] = i
		if m[i] == 'L':
			x -= 1
		elif m[i] == 'R':
			x += 1
		elif m[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in vis:
			done = True
			ans.append([vis[x, y] + 1, i + 1])
	if not done:
		print(-1)
	else:
		mini = n + 1
		res = []
		for i in ans:
			if i[1] - i[0] + 1 < mini:
				mini = i[1] - i[0] + 1
				res = [i[0], i[1]]
		print(res[0], res[1])


def chkd(dd, pp):
	pp = tuple(pp)
	if pp in dd:
		return dd[pp]
	else:
		return -233
t = int(input())
for ti in range(t):
	n = int(input())
	s = input()
	pos = [0, 0]
	d = {tuple(pos): 0}
	ans = 19260817
	for (ind, i) in enumerate(s):
		if i == 'L':
			pos[0] -= 1
			sta = chkd(d, pos)
			if sta != -233:
				if ind - sta < ans:
					al = sta
					ar = ind
					ans = ind - sta
			d[tuple(pos)] = ind + 1
		elif i == 'R':
			pos[0] += 1
			sta = chkd(d, pos)
			if sta != -233:
				if ind - sta < ans:
					al = sta
					ar = ind
					ans = ind - sta
			d[tuple(pos)] = ind + 1
		elif i == 'U':
			pos[1] += 1
			sta = chkd(d, pos)
			if sta != -233:
				if ind - sta < ans:
					al = sta
					ar = ind
					ans = ind - sta
			d[tuple(pos)] = ind + 1
		elif i == 'D':
			pos[1] -= 1
			sta = chkd(d, pos)
			if sta != -233:
				if ind - sta < ans:
					al = sta
					ar = ind
					ans = ind - sta
			d[tuple(pos)] = ind + 1
	if ans != 19260817:
		print(al + 1, ar + 1)
	else:
		print(-1)


import functools
import math

def sol(ls):
	vis = {(0, 0): 1}
	coor = [0, 0]
	minz = math.inf
	ind = 1
	res = (-1, -1)
	for v in ls:
		if v == 'L':
			coor[0] -= 1
		elif v == 'R':
			coor[0] += 1
		elif v == 'U':
			coor[1] += 1
		else:
			coor[1] -= 1
		if (coor[0], coor[1]) in vis:
			val = ind - vis[coor[0], coor[1]] + 1
			if val < minz:
				minz = val
				res = (vis[coor[0], coor[1]], ind)
		ind += 1
		vis[coor[0], coor[1]] = ind
	return res
t = int(input().strip())
for i in range(t):
	_ = int(input().strip())
	ls = input().strip()
	r = sol(ls)
	if r == (-1, -1):
		print(-1)
	else:
		print(r[0], r[1])


import sys
import math
import heapq
import collections

def inputnum():
	return int(input())

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

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

def inputstring():
	return [x for x in input()]

def inputstringnum():
	return [ord(x) - ord('a') for x in input()]

def inputmatrixchar(rows):
	arr2d = [[j for j in input().strip()] for i in range(rows)]
	return arr2d

def inputmatrixint(rows):
	arr2d = []
	for _ in range(rows):
		arr2d.append([int(i) for i in input().split()])
	return arr2d
t = int(input())
for q in range(t):
	n = inputnum()
	s = inputstring()
	p = (0, 0)
	d = {p: 0}
	l = -1
	r = -1
	mn = n + 1
	for i in range(n):
		(first, second) = p
		if s[i] == 'U':
			p = (first, second + 1)
		if s[i] == 'D':
			p = (first, second - 1)
		if s[i] == 'R':
			p = (first + 1, second)
		if s[i] == 'L':
			p = (first - 1, second)
		if d.get(p, -1) != -1:
			if i + 1 - d[p] < mn:
				l = d[p] + 1
				r = i + 1
				mn = i + 1 - d[p]
		d[p] = i + 1
	if l == -1 or r == -1:
		print(-1)
	else:
		print(l, r)


def main():
	n = int(input())
	string = str(input())
	d = {}
	x = 0
	y = 0
	l = -1
	r = n + 1
	d[x, y] = 0
	for i in range(len(string)):
		if string[i] == 'L':
			x -= 1
		if string[i] == 'R':
			x += 1
		if string[i] == 'U':
			y += 1
		if string[i] == 'D':
			y -= 1
		if d.get((x, y)) != None:
			if i - d[x, y] + 1 < r - l + 1:
				l = d[x, y]
				r = i
		d[x, y] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)
	return

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


t = int(input())
for i in range(t):
	n = int(input())
	path = [i for i in input()]
	dict1 = dict()
	dict1[0, 0] = 0
	verti = 0
	hori = 0
	min_ = 200002
	ok = False
	for i in range(len(path)):
		if path[i] == 'L':
			hori += 1
		elif path[i] == 'R':
			hori -= 1
		elif path[i] == 'U':
			verti += 1
		else:
			verti -= 1
		if (hori, verti) in dict1:
			ok = True
			op = int(dict1[hori, verti] + 1)
			dict1[hori, verti] = i + 1
			min2 = i + 2 - (op - 1)
			if min2 < min_:
				min_ = min2
				ans = [op, i + 1]
		else:
			dict1[hori, verti] = i + 1
	if ok == True:
		print(*ans)
	else:
		print(-1)


t1 = int(input())
while t1 > 0:
	t1 -= 1
	n = int(input())
	dic = {}
	x = 0
	y = 0
	index = 0
	dic['0 0'] = [0]
	s = input()
	for i in s:
		index += 1
		if i == 'L':
			x = x - 1
		elif i == 'R':
			x = x + 1
		elif i == 'U':
			y = y + 1
		elif i == 'D':
			y = y - 1
		temp = str(x) + ' ' + str(y)
		if temp in dic:
			dic[temp].append(index)
		else:
			dic[temp] = [index]
	l = 0
	r = 0
	Min = -1
	for i in dic:
		temp = dic[i]
		for j in range(len(temp) - 1):
			t = temp[j + 1] - temp[j]
			if Min == -1:
				Min = t
				l = temp[j]
				r = temp[j + 1]
			elif Min > t:
				Min = t
				l = temp[j]
				r = temp[j + 1]
	if Min == -1:
		print(-1)
	else:
		print(l + 1, r)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {(0, 0): 1}
	(x, y) = (0, 0)
	ans = float('inf')
	to_print = [0, 0]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			if i - d[x, y] < ans:
				ans = i - d[x, y]
				to_print[0] = d[x, y]
				to_print[1] = i + 1
		d[x, y] = i + 2
	if ans == float('inf'):
		print(-1)
	else:
		print(*to_print)


for t in range(int(input())):
	n = int(input())
	s = list(input())
	(x, y) = (0, 0)
	size = float('inf')
	index = {}
	flag = True
	index[x, y] = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if index.get((x, y), -1) != -1:
			k = index[x, y]
			if size > i + 1 - k:
				(st, ed) = (k + 1, i + 1)
				size = i + 1 - k
		index[x, y] = i + 1
	if size != float('inf'):
		print(st, ed)
	else:
		print(-1)


T = int(input())
for t in range(T):
	n = int(input())
	a = input()
	x = 0
	y = 0
	dt = dict()
	dt[0, 0] = -1
	ans = 1000000000.0
	l = -1
	r = -1
	for i in range(n):
		if a[i] == 'L':
			x -= 1
		elif a[i] == 'R':
			x += 1
		elif a[i] == 'U':
			y += 1
		elif a[i] == 'D':
			y -= 1
		pos = (x, y)
		prev = dt.get(pos)
		if prev is not None:
			length = i - prev
			if length < ans:
				ans = length
				l = prev + 1
				r = i
		dt[pos] = i
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	l = [[0 + (s[0] == 'R') - (s[0] == 'L'), 0 + (s[0] == 'U') - (s[0] == 'D'), 0]]
	for i in range(1, len(s)):
		x = (s[i] == 'R') - (s[i] == 'L')
		y = (s[i] == 'U') - (s[i] == 'D')
		l.append([l[i - 1][0] + x, l[i - 1][1] + y, i])
	l.append([0, 0, -1])
	l.sort()
	minn = 200003
	for i in range(len(l) - 1):
		if l[i][0] == l[i + 1][0] and l[i][1] == l[i + 1][1]:
			if minn > l[i + 1][2] - l[i][2]:
				minn = l[i + 1][2] - l[i][2]
				ans = [l[i][2] + 2, l[i + 1][2] + 1]
	if minn == 200003:
		print(-1)
	else:
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	a = input()
	(dx, dy) = (0, 0)
	c = {}
	c[dx, dy] = 0
	ans = [-1]
	for i in range(n):
		x = a[i]
		if 'L' == x:
			dx -= 1
		elif 'R' == x:
			dx += 1
		elif 'U' == x:
			dy += 1
		else:
			dy -= 1
		key = (dx, dy)
		if key in c:
			x = i + 1 - c[key]
			if x > 0 and ans[0] < 0 or x < ans[1] - ans[0] + 1:
				ans = [c[key] + 1, i + 1]
		c[key] = i + 1
	print(' '.join(map(str, ans)))


import sys, bisect, string, math, time, functools, random, fractions
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
from itertools import permutations, combinations, groupby
rep = range
R = range

def Golf():
	(n, *t) = map(int, open(0).read().split())

def I():
	return int(input())

def S_():
	return input()

def IS():
	return input().split()

def LS():
	return [i for i in input().split()]

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

def LI():
	return [int(i) for i in input().split()]

def LI_():
	return [int(i) - 1 for i in input().split()]

def NI(n):
	return [int(input()) for i in range(n)]

def NI_(n):
	return [int(input()) - 1 for i in range(n)]

def StoLI():
	return [ord(i) - 97 for i in input()]

def ItoS(n):
	return chr(n + 97)

def LtoS(ls):
	return ''.join([chr(i + 97) for i in ls])

def RA():
	return map(int, open(0).read().split())

def RLI(n=8, a=1, b=10):
	return [random.randint(a, b) for i in range(n)]

def RI(a=1, b=10):
	return random.randint(a, b)

def Rtest(T):
	(case, err) = (0, 0)
	for i in range(T):
		inp = INP()
		(a1, ls) = naive(*inp)
		a2 = solve(*inp)
		if a1 != a2:
			print((a1, a2), inp)
			err += 1
		case += 1
	print('Tested', case, 'case with', err, 'errors')

def GI(V, E, ls=None, Directed=False, index=1):
	org_inp = []
	g = [[] for i in range(V)]
	FromStdin = True if ls == None else False
	for i in range(E):
		if FromStdin:
			inp = LI()
			org_inp.append(inp)
		else:
			inp = ls[i]
		if len(inp) == 2:
			(a, b) = inp
			c = 1
		else:
			(a, b, c) = inp
		if index == 1:
			a -= 1
			b -= 1
		aa = (a, c)
		bb = (b, c)
		g[a].append(bb)
		if not Directed:
			g[b].append(aa)
	return (g, org_inp)

def GGI(h, w, search=None, replacement_of_found='.', mp_def={'#': 1, '.': 0}, boundary=1):
	mp = [boundary] * (w + 2)
	found = {}
	for i in R(h):
		s = input()
		for char in search:
			if char in s:
				found[char] = (i + 1) * (w + 2) + s.index(char) + 1
				mp_def[char] = mp_def[replacement_of_found]
		mp += [boundary] + [mp_def[j] for j in s] + [boundary]
	mp += [boundary] * (w + 2)
	return (h + 2, w + 2, mp, found)

def TI(n):
	return GI(n, n - 1)

def accum(ls):
	rt = [0]
	for i in ls:
		rt += [rt[-1] + i]
	return rt

def bit_combination(n, base=2):
	rt = []
	for tb in R(base ** n):
		s = [tb // base ** bt % base for bt in R(n)]
		rt += [s]
	return rt

def gcd(x, y):
	if y == 0:
		return x
	if x % y == 0:
		return y
	while x % y != 0:
		(x, y) = (y, x % y)
	return y

def YN(x):
	print(['NO', 'YES'][x])

def Yn(x):
	print(['No', 'Yes'][x])

def show(*inp, end='\n'):
	if show_flg:
		print(*inp, end=end)
mo = 10 ** 9 + 7
inf = float('inf')
FourNb = [(-1, 0), (1, 0), (0, 1), (0, -1)]
EightNb = [(-1, 0), (1, 0), (0, 1), (0, -1), (1, 1), (-1, -1), (1, -1), (-1, 1)]
compas = dict(zip('WENS', FourNb))
cursol = dict(zip('LRUD', FourNb))
l_alp = string.ascii_lowercase
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
input = lambda : sys.stdin.readline().rstrip()

class Comb:

	def __init__(self, n, mo=10 ** 9 + 7):
		self.fac = [0] * (n + 1)
		self.inv = [1] * (n + 1)
		self.fac[0] = 1
		self.fact(n)
		self.mo = mo
		for i in range(1, n + 1):
			self.fac[i] = i * self.fac[i - 1] % mo
			self.inv[n] *= i
			self.inv[n] %= mo
		self.inv[n] = pow(self.inv[n], mo - 2, mo)
		for i in range(1, n):
			self.inv[n - i] = self.inv[n - i + 1] * (n - i + 1) % mo
		return

	def fact(self, n):
		return self.fac[n]

	def invf(self, n):
		return self.inv[n]

	def comb(self, x, y):
		if y < 0 or y > x:
			return 0
		return self.fac[x] * self.inv[x - y] * self.inv[y] % self.mo
show_flg = False
show_flg = True
ans = 0
for _ in range(I()):
	n = I()
	s = input()
	(x, y) = (0, 0)
	d = {}
	d[0, 0] = 0
	ans = [-1]
	ans = [-1]
	p = n + 1
	for i in range(n):
		(dx, dy) = cursol[s[i]]
		x += dx
		y += dy
		if (x, y) in d:
			tmp = i - d[x, y]
			if tmp < p:
				p = tmp
				ans = [d[x, y] + 1, i + 1]
		d[x, y] = i + 1
	print(*ans)


INF = 1000000000
move = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	(l, r) = (-INF, INF)
	pos = (0, 0)
	vis = dict({(0, 0): 0})
	for (i, si) in enumerate(s, 1):
		pos = tuple((x + y for (x, y) in zip(pos, move[si])))
		if pos in vis:
			j = vis[pos] + 1
			if i - j + 1 < r - l + 1:
				(l, r) = (j, i)
		vis[pos] = i
	if r - l + 1 < INF:
		print(l, r)
	else:
		print(-1)


from sys import maxsize
for _ in range(int(input())):
	n = int(input())
	s = input()
	dp = dict()
	(x, y) = (0, 0)
	dp[x, y] = 0
	(l, r) = (-1, maxsize)
	for i in range(n):
		if s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		elif s[i] == 'L':
			x -= 1
		else:
			x += 1
		if (x, y) in dp.keys():
			if r - l > i - dp[x, y]:
				(r, l) = (i, dp[x, y])
		dp[x, y] = i + 1
	if l != -1:
		print(l + 1, r + 1)
		continue
	print(-1)


from collections import defaultdict
from os import system
import sys
import queue

class Cord:

	def __init__(self):
		self.x = 0
		self.y = 0
for _ in range(int(input())):
	n = int(input())
	path = input()
	carry = defaultdict(list)
	carry[0, 0].append(-1)
	plane = Cord()
	for i in range(len(path)):
		if path[i] == 'L':
			plane.x -= 1
		elif path[i] == 'R':
			plane.x += 1
		elif path[i] == 'U':
			plane.y += 1
		elif path[i] == 'D':
			plane.y -= 1
		carry[plane.x, plane.y].append(i)
	val = []
	for (x, y) in carry.items():
		if len(y) > 1:
			for i in range(len(y) - 1):
				val.append((abs(y[i] - y[i + 1]), (y[i], y[i + 1])))
	val.sort(key=lambda x: x[0])
	if len(val) == 0:
		print(-1)
	else:
		print(val[0][1][0] + 2, val[0][1][1] + 1)


import sys
reader = (line.rstrip() for line in sys.stdin)
input = reader.__next__
t = int(input())
for _ in range(t):
	n = int(input())
	coms = list(input())
	pos = {(0, 0): -1}
	x = y = 0
	l = -1
	r = float('inf')
	for (i, d) in enumerate(coms):
		if d == 'L':
			x -= 1
		elif d == 'R':
			x += 1
		elif d == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in pos:
			prev = pos[x, y]
			if i - prev < r - l:
				(r, l) = (i, prev)
		pos[x, y] = i
	if r == float('inf'):
		print(-1)
	else:
		print(l + 2, r + 1)


t = int(input())
while t:
	n = int(input())
	s = input()
	d = dict()
	d[0, 0] = -1
	si = ei = 0
	x = y = 0
	temp = 10 ** 9
	for i in range(n):
		if s[i] == 'L':
			x = x - 1
		elif s[i] == 'R':
			x = x + 1
		elif s[i] == 'U':
			y = y + 1
		else:
			y = y - 1
		tu = (x, y)
		if tu in d:
			xs = i - d[tu]
			temp = min(temp, xs)
			if temp == xs:
				si = d[tu] + 1
				ei = i
		d[tu] = i
	if si == 0 and ei == 0:
		print(-1)
	else:
		print(si + 1, end=' ')
		print(ei + 1)
	t -= 1


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	k = {'0,0': -1}
	flag = 0
	res = 9999999999
	for j in range(len(s)):
		if s[j] == 'R':
			x += 1
		elif s[j] == 'L':
			x -= 1
		elif s[j] == 'U':
			y += 1
		else:
			y -= 1
		srr = str(x) + ',' + str(y)
		if srr in k:
			if j - (k[srr] + 1) < res:
				res = j - (k[srr] + 1)
				flag = 1
				ressr = str(k[srr] + 2) + ' ' + str(j + 1)
			k[srr] = j
		else:
			k[srr] = j
	if flag == 0:
		print(-1)
	else:
		print(ressr)


for _ in range(int(input())):
	n = int(input())
	s = input()
	cnt = 0
	l = [[0, 0, 0]]
	m = 200010
	(a, b) = (0, 0)
	for x in s:
		cnt += 1
		if x == 'L':
			l.append([l[-1][0] - 1, l[-1][1], cnt])
		elif x == 'R':
			l.append([l[-1][0] + 1, l[-1][1], cnt])
		elif x == 'U':
			l.append([l[-1][0], l[-1][1] + 1, cnt])
		elif x == 'D':
			l.append([l[-1][0], l[-1][1] - 1, cnt])
	l.sort()
	for x in range(n):
		if l[x][0] == l[x + 1][0] and l[x][1] == l[x + 1][1]:
			if l[x + 1][2] - l[x][2] < m:
				m = l[x + 1][2] - l[x][2]
				(a, b) = (l[x][2] + 1, l[x + 1][2])
	if m == 200010:
		print(-1)
	else:
		print(a, b)


def move(ls, chr):
	if chr == 'L':
		return (ls[0] - 1, ls[1])
	elif chr == 'R':
		return (ls[0] + 1, ls[1])
	elif chr == 'U':
		return (ls[0], ls[1] + 1)
	elif chr == 'D':
		return (ls[0], ls[1] - 1)
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	ans = [0, 10 ** 9]
	ls = [(0, 0)]
	st = {(0, 0)}
	for i in range(1, n + 1):
		stbefore = len(st)
		addls = move(ls[i - 1], s[i - 1])
		ls.append(addls)
		st.add(addls)
		if len(st) == stbefore:
			count = ans[1] - ans[0]
			for j in reversed(range(len(ls) - 1)):
				count -= 1
				if ls[j] == addls:
					if i - (j + 1) < ans[1] - ans[0]:
						ans = [j + 1, i]
				if count < 0:
					break
	if ans == [0, 10 ** 9]:
		print(-1)
	else:
		print(*ans)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, d) = ([0, 0], {(0, 0): -1})
	ans = [-float('inf'), float('inf')]
	for q in range(len(s)):
		if s[q] == 'U':
			x[0] += 1
		elif s[q] == 'D':
			x[0] -= 1
		elif s[q] == 'R':
			x[1] += 1
		else:
			x[1] -= 1
		if (x[0], x[1]) in d and ans[1] - ans[0] > q - d[x[0], x[1]]:
			ans = [d[x[0], x[1]] + 1, q]
		d[x[0], x[1]] = q
	if ans[0] == -float('inf'):
		print(-1)
	else:
		print(ans[0] + 1, ans[1] + 1)


directions = {'L': (-1, 0), 'R': (1, 0), 'D': (0, -1), 'U': (0, 1)}
t = int(input())
for i in range(t):
	n = int(input())
	s = [directions[i] for i in input()]
	point_x = 0
	point_y = 0
	history = {(0, 0): 0}
	best_substring_start = 0
	best_substring_end = n
	solution_found = False
	for j in range(n):
		point_x += s[j][0]
		point_y += s[j][1]
		if (point_x, point_y) in history:
			solution_found = True
			if best_substring_end - best_substring_start > j + 1 - history[point_x, point_y]:
				best_substring_end = j + 1
				best_substring_start = history[point_x, point_y]
		history[point_x, point_y] = j + 1
	if solution_found:
		print(best_substring_start + 1, best_substring_end)
	else:
		print(-1)


import sys
input = sys.stdin.readline
INF = 10 ** 9
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().rstrip()
	x = 0
	y = 0
	seen = {(0, 0): 0}
	min_len = INF
	ans = None
	for (i, ch) in enumerate(s):
		if ch == 'L':
			y -= 1
		elif ch == 'R':
			y += 1
		elif ch == 'U':
			x -= 1
		elif ch == 'D':
			x += 1
		if (x, y) not in seen:
			seen[x, y] = i + 1
			continue
		l = seen[x, y]
		if i - l < min_len:
			ans = (l + 1, i + 1)
			min_len = i - l
		seen[x, y] = i + 1
	if ans == None:
		print(-1)
	else:
		print(*ans)


import sys
from collections import defaultdict as dd

def data():
	return sys.stdin.readline().strip()

def out(var):
	sys.stdout.write(str(var))

def l():
	return list(sp())

def strl():
	return list(strsp())

def sp():
	return map(int, data().split())

def strsp():
	return map(str, data().split())
for _ in range(int(data())):
	r = float('inf')
	n = int(data())
	s = data()
	k = 0
	(x, y) = (0, 0)
	g = dd(list)
	(u, v) = (0, 0)
	g[0, 0] = [0]
	for i in range(n):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if g.get((x, y)) == None:
			g[x, y].append(i + 1)
		else:
			a = g[x, y][-1]
			g[x, y].append(i + 1)
			if r > i + 1 - a:
				r = i + 1 - a
				u = a + 1
				v = i + 1
	if r != float('inf'):
		print(u, v)
	else:
		print(-1)


INF = float('inf')
for i in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	d = {(0, 0): 0}
	m = INF
	mi = -1
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in d:
			if m > i + 1 - d[x, y]:
				m = i + 1 - d[x, y]
				mi = i + 1
		d[x, y] = i + 1
	if mi == -1:
		print(-1)
	else:
		print(mi - m + 1, mi)


q = int(input())
for i in range(q):
	n = int(input())
	s = input()
	A = {}
	k = n + 1
	(x, y) = (0, 0)
	A[0] = {}
	A[0][0] = -1
	for j in range(n):
		if s[j] == 'L':
			x -= 1
		elif s[j] == 'R':
			x += 1
		elif s[j] == 'U':
			y += 1
		else:
			y -= 1
		if x not in A:
			A[x] = {}
			A[x][y] = j
		elif y not in A[x]:
			A[x][y] = j
		else:
			l = A[x][y]
			if j - l < k:
				k = j - l
				(a, b) = (l, j)
			A[x][y] = j
	if k == n + 1:
		print(-1)
	else:
		print(a + 2, b + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	m = {}
	m[x, y] = 0
	ans = float('inf')
	pt = [-1, -1]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in m.keys():
			if i + 1 - m[x, y] < ans:
				ans = i + 1 - m[x, y]
				pt[0] = m[x, y] + 1
				pt[1] = i + 1
		m[x, y] = i + 1
	if ans == float('inf'):
		print(-1)
	else:
		print(*pt)


import sys, bisect
from collections import defaultdict, Counter, deque

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

def print(arg, *argv, end=None):
	sys.stdout.write(str(arg))
	for i in argv:
		sys.stdout.write(' ' + str(i))
	sys.stdout.write(end) if end or end == '' else sys.stdout.write('\n')

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

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

def solve():
	t = 1
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input().strip()
		st = (0, 0)
		mp = {}
		id1 = 0
		id2 = 0
		fl1 = True
		fl2 = True
		mp[st] = 0
		last = float('inf')
		id1 = -1
		id2 = -1
		for i in range(1, n + 1):
			(x, y) = st
			if s[i - 1] == 'U':
				y -= 1
			elif s[i - 1] == 'D':
				y += 1
			elif s[i - 1] == 'L':
				x -= 1
			elif s[i - 1] == 'R':
				x += 1
			if (x, y) in mp:
				if i - mp[x, y] + 1 < last:
					(id1, id2) = (mp[x, y], i)
					last = id2 - id1 + 1
				mp[x, y] = i
			else:
				mp[x, y] = i
			st = (x, y)
		if id1 == id2:
			print(-1)
		else:
			print(id1 + 1, id2)
solve()


test = int(input())
for t in range(test):
	n = int(input())
	s = input()
	m = {}
	x = 0
	y = 0
	c = False
	r = -1
	l = -1
	lnn = 1000000
	m[x, y] = 0
	for i in range(n):
		if s[i] == 'R':
			x += 1
		if s[i] == 'L':
			x -= 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in m:
			ln = i - m[x, y] + 1
			if ln < lnn:
				lnn = ln
				l = m[x, y] + 1
				r = i + 1
			c = True
		m[x, y] = i + 1
	if not c:
		print(-1)
	else:
		print(l, r)


t = int(input())
from collections import defaultdict
for _ in range(t):
	n = int(input())
	s = input()
	curr = [0, 0]
	m = defaultdict(int)
	left = -1
	right = n
	m[0, 0] = 0
	for (n, i) in enumerate(s):
		if i == 'U':
			curr[1] += 1
		elif i == 'D':
			curr[1] -= 1
		elif i == 'R':
			curr[0] += 1
		elif i == 'L':
			curr[0] -= 1
		t = tuple(curr)
		if t in m:
			if n - m[t] + 1 < right - left + 1:
				left = m[t]
				right = n
		m[t] = n + 1
	if left == -1:
		print(-1)
	else:
		print(left + 1, right + 1)


for t in range(int(input())):
	n = int(input())
	s = input()
	a = []
	(i, j) = (0, 0)
	a.append([0, 0, 0])
	for k in range(n):
		if s[k] == 'L':
			a.append([i, j - 1, k + 1])
			j -= 1
		elif s[k] == 'R':
			a.append([i, j + 1, k + 1])
			j += 1
		elif s[k] == 'U':
			a.append([i - 1, j, k + 1])
			i -= 1
		else:
			a.append([i + 1, j, k + 1])
			i += 1
	a.sort()
	mini = 999999999999
	(l, r) = (0, 0)
	for i in range(1, n + 1):
		if a[i][0] == a[i - 1][0] and a[i][1] == a[i - 1][1]:
			if mini > a[i][2] - a[i - 1][2]:
				mini = a[i][2] - a[i - 1][2]
				l = a[i - 1][2] + 1
				r = a[i][2]
	if mini == 999999999999:
		print(-1)
	else:
		print(l, r)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	f = 0
	r = 0
	l = 0
	for i in range(1, n):
		if s[i] == 'L':
			if s[i - 1] == 'R':
				f = 1
				r = i
				l = i - 1
				break
		elif s[i] == 'R':
			if s[i - 1] == 'L':
				f = 1
				r = i
				l = i - 1
				break
		elif s[i] == 'U':
			if s[i - 1] == 'D':
				f = 1
				r = i
				l = i - 1
				break
		elif s[i - 1] == 'U':
			f = 1
			r = i
			l = i - 1
			break
	if f == 1:
		print(l + 1, r + 1)
	else:
		d = {(0, 0): 0}
		x = 0
		y = 0
		l = 0
		r = n
		g = 0
		for i in range(n):
			if s[i] == 'L':
				x = x - 1
				if (x, y) in d:
					g = 1
					if i + 1 - d[x, y] + 1 <= r - l + 1:
						r = i + 1
						l = d[x, y]
				d[x, y] = i + 1
			elif s[i] == 'R':
				x = x + 1
				if (x, y) in d:
					g = 1
					if i + 1 - d[x, y] + 1 <= r - l + 1:
						r = i + 1
						l = d[x, y]
				d[x, y] = i + 1
			elif s[i] == 'U':
				y = y + 1
				if (x, y) in d:
					g = 1
					if i + 1 - d[x, y] + 1 <= r - l + 1:
						r = i + 1
						l = d[x, y]
				d[x, y] = i + 1
			else:
				y = y - 1
				if (x, y) in d:
					g = 1
					if i + 1 - d[x, y] + 1 <= r - l + 1:
						r = i + 1
						l = d[x, y]
				d[x, y] = i + 1
		if g == 0:
			print(-1)
		else:
			print(l + 1, r)


n = int(input())
result = []
for i in range(n):
	m = int(input())
	path = input()
	x = 0
	y = 0
	length = m + 1
	to_drop = []
	coords = ['0#0']
	for move in path:
		if move == 'L':
			x -= 1
		elif move == 'R':
			x += 1
		elif move == 'U':
			y += 1
		elif move == 'D':
			y -= 1
		coords.append(str(x) + '#' + str(y))
	loops = {}
	for (i, point) in enumerate(coords):
		if point not in loops:
			loops[point] = [i]
		else:
			loops[point].append(i)
	left = 0
	right = 0
	for p in loops:
		for i in range(1, len(loops[p])):
			d = loops[p][i] - loops[p][i - 1]
			if d < length:
				length = d
				left = loops[p][i - 1] + 1
				right = loops[p][i]
	if length == m + 1:
		result.append(str(-1))
	else:
		result.append(str(left) + ' ' + str(right))
for item in result:
	print(item)


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	min_distance = n + 1
	point = [0, 0]
	points = {tuple(point): 0}
	ans = None
	for i in range(1, n + 1):
		if s[i - 1] == 'L':
			point[0] -= 1
		elif s[i - 1] == 'R':
			point[0] += 1
		elif s[i - 1] == 'U':
			point[1] += 1
		elif s[i - 1] == 'D':
			point[1] -= 1
		hashed = tuple(point)
		if hashed in points and i - points[hashed] < min_distance:
			min_distance = i - points[hashed]
			ans = (points[hashed] + 1, i)
		points[hashed] = i
	print(str(ans[0]) + ' ' + str(ans[1]) if min_distance != n + 1 else -1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	a = 0
	b = 0
	dic = {}
	for i in s:
		if i == 'L':
			a -= 1
			dic[a, b] = 0
		elif i == 'R':
			a += 1
			dic[a, b] = 0
		elif i == 'D':
			b -= 1
			dic[a, b] = 0
		else:
			b += 1
			dic[a, b] = 0
	a = 0
	b = 0
	ans = float('inf')
	l = -1
	r = -1
	j = 1
	dic[a, b] = 0
	for i in s:
		if i == 'L':
			a -= 1
		elif i == 'R':
			a += 1
		elif i == 'D':
			b -= 1
		else:
			b += 1
		if dic[a, b] == 0 and (a != 0 or b != 0):
			dic[a, b] = j
		else:
			if ans > j - dic[a, b]:
				l = dic[a, b] + 1
				r = j
				ans = r - l + 1
			dic[a, b] = j
		j += 1
	if l == 0:
		l = 1
	if l == -1 and r == -1:
		print(-1)
	else:
		print(l, r)


t = 1
t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	pos = [0, 0]
	last = {}
	last[0, 0] = 0
	(l, r) = (-1, n)
	for i in range(n):
		if s[i] == 'L':
			pos[0] -= 1
		if s[i] == 'R':
			pos[0] += 1
		if s[i] == 'D':
			pos[1] -= 1
		if s[i] == 'U':
			pos[1] += 1
		if (pos[0], pos[1]) in last:
			if r - l + 1 > i - last[pos[0], pos[1]] + 1:
				l = last[pos[0], pos[1]]
				r = i
		last[pos[0], pos[1]] = i + 1
	if l is -1:
		print(-1)
	else:
		print(l + 1, r + 1)


for _ in ' ' * int(input()):
	a = int(input())
	d = dict()
	d[0, 0] = [0]
	x = y = 0
	p = 1
	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) in d:
			d[x, y].append(p)
		else:
			d[x, y] = [p]
		p += 1
	k = a + 1
	(i1, i2) = (-1, -1)
	for i in d.values():
		if len(i) != 1:
			for j in range(len(i) - 1):
				if k > i[j + 1] - i[j]:
					i1 = i[j]
					i2 = i[j + 1]
					k = i2 - i1
	if i1 == -1:
		print(i1)
	else:
		print(i1 + 1, i2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	d = {}
	d[0, 0] = -1
	ans = float('INF')
	for (idx, i) in enumerate(s):
		if i == 'L':
			x += 1
		elif i == 'R':
			x -= 1
		elif i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		if (x, y) in d:
			prev = d[x, y] + 1
			dt = idx - prev + 1
			if dt < ans:
				ans = dt
				left = prev + 1
				right = idx + 1
		d[x, y] = idx
	if ans > n:
		print(-1)
	else:
		print(left, right)


kl = int(input())
for l in range(kl):
	n = int(input())
	s = str(input())
	b = set()
	d = {}
	x = 0
	y = 0
	mn = n + 1
	mnp = [0, 0]
	b.add((0, 0))
	d[0, 0] = 0
	for i in range(1, n + 1):
		if s[i - 1] == 'L':
			x -= 1
		if s[i - 1] == 'R':
			x += 1
		if s[i - 1] == 'U':
			y += 1
		if s[i - 1] == 'D':
			y -= 1
		if (x, y) in b:
			k = d[x, y]
			if i - k < mn:
				mnp = [k + 1, i]
				mn = i - k
		d[x, y] = i
		b.add((x, y))
	if mn != n + 1:
		print(mnp[0], mnp[1])
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	dp = {(0, 0): 1}
	p = [0, 0]
	(r, l, ind) = (n, 0, 1)
	for i in a:
		if i == 'L':
			p[0] -= 1
		elif i == 'R':
			p[0] += 1
		elif i == 'U':
			p[1] += 1
		elif i == 'D':
			p[1] -= 1
		p = tuple(p)
		if p in dp and r - l > ind - dp[p]:
			(l, r) = (dp[p], ind)
		ind += 1
		dp[p] = ind
		p = list(p)
	if l:
		print(l, r)
	else:
		print(-1)


t = int(input())
while t != 0:
	n = int(input())
	moveArr = list(input())
	xArr = [0] * (len(moveArr) + 1)
	yArr = [0] * (len(moveArr) + 1)
	moveDict = dict()
	moveDict[0, 0] = []
	moveDict[0, 0].append(0)
	result = '-1'
	minDist = 10000000
	for i in range(len(moveArr)):
		if moveArr[i] == 'L':
			xArr[i + 1] = xArr[i] - 1
			yArr[i + 1] = yArr[i]
		if moveArr[i] == 'R':
			xArr[i + 1] = xArr[i] + 1
			yArr[i + 1] = yArr[i]
		if moveArr[i] == 'U':
			yArr[i + 1] = yArr[i] + 1
			xArr[i + 1] = xArr[i]
		if moveArr[i] == 'D':
			yArr[i + 1] = yArr[i] - 1
			xArr[i + 1] = xArr[i]
		if (xArr[i + 1], yArr[i + 1]) in moveDict:
			oldPos = moveDict[xArr[i + 1], yArr[i + 1]].pop()
			if minDist > i + 1 - oldPos:
				minDist = i + 1 - oldPos
				result = '{} {}'.format(oldPos + 1, i + 1)
			moveDict[xArr[i + 1], yArr[i + 1]].append(i + 1)
		else:
			moveDict[xArr[i + 1], yArr[i + 1]] = []
			moveDict[xArr[i + 1], yArr[i + 1]].append(i + 1)
	print(result)
	t -= 1


from sys import stdin, stdout

def INI():
	return int(stdin.readline())

def INL():
	return [int(_) for _ in stdin.readline().split()]

def INS():
	return stdin.readline()

def MOD():
	return pow(10, 9) + 7

def OPS(ans):
	stdout.write(str(ans) + '\n')

def OPL(ans):
	[stdout.write(str(_) + ' ') for _ in ans]
	stdout.write('\n')
for _ in range(INI()):
	n = INI()
	S = INS()
	(x, y) = (0, 0)
	D = dict()
	D[x, y] = [-1]
	ans = float('inf')
	ANS = []
	for _ in range(n):
		if S[_] == 'L':
			x -= 1
		elif S[_] == 'R':
			x += 1
		elif S[_] == 'D':
			y -= 1
		else:
			y += 1
		if (x, y) in D:
			u = _ - D[x, y][-1]
			if u < ans:
				ANS = [D[x, y][-1] + 2, _ + 1]
				ans = u
		D[x, y] = [_]
	if ANS == []:
		OPS(-1)
	else:
		OPL(ANS)


from __future__ import division, print_function
import os, sys
from io import BytesIO, IOBase
if sys.version_info[0] < 3:
	from __builtin__ import xrange as range
	from future_builtins import ascii, filter, hex, map, oct, zip

def ii():
	return int(input())

def si():
	return input()

def mi():
	return map(int, input().strip().split(' '))

def msi():
	return map(str, input().strip().split(' '))

def li():
	return list(mi())

def dmain():
	sys.setrecursionlimit(100000000)
	threading.stack_size(40960000)
	thread = threading.Thread(target=main)
	thread.start()
from math import ceil, floor, log, sqrt, factorial
abc = 'abcdefghijklmnopqrstuvwxyz'
abd = {'a': 0, 'b': 1, 'c': 2, 'd': 3, 'e': 4, 'f': 5, 'g': 6, 'h': 7, 'i': 8, 'j': 9, 'k': 10, 'l': 11, 'm': 12, 'n': 13, 'o': 14, 'p': 15, 'q': 16, 'r': 17, 's': 18, 't': 19, 'u': 20, 'v': 21, 'w': 22, 'x': 23, 'y': 24, 'z': 25}
mod = 1000000007
inf = float('inf')
vow = ['a', 'e', 'i', 'o', 'u']
(dx, dy) = ([-1, 1, 0, 0], [0, 0, 1, -1])

def getKey(item):
	return item[1]

def sort2(l):
	return sorted(l, key=getKey, reverse=True)

def d2(n, m, num):
	return [[num for x in range(m)] for y in range(n)]

def isPowerOfTwo(x):
	return x and (not x & x - 1)

def decimalToBinary(n):
	return bin(n).replace('0b', '')

def ntl(n):
	return [int(i) for i in str(n)]

def powerMod(x, y, p):
	res = 1
	x %= p
	while y > 0:
		if y & 1:
			res = res * x % p
		y = y >> 1
		x = x * x % p
	return res

def gcd(x, y):
	while y:
		(x, y) = (y, x % y)
	return x

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def read():
	sys.stdin = open('input.txt', 'r')
	sys.stdout = open('output.txt', 'w')

def main():
	for _ in range(ii()):
		n = ii()
		s = list(si())
		lr = [0] * (n + 5)
		ud = [0] * (n + 5)
		x = 0
		y = 0
		ss = [[0, 0, -1]]
		for i in range(n):
			if s[i] == 'L':
				x -= 1
			if s[i] == 'R':
				x += 1
			if s[i] == 'U':
				y += 1
			if s[i] == 'D':
				y -= 1
			ss.append([x, y, i])
		ss.sort()
		ans = inf
		xx = 0
		yy = 0
		n += 1
		for i in range(n - 1):
			if ss[i][0] == ss[i + 1][0] and ss[i][1] == ss[i + 1][1]:
				d = abs(ss[i][2] - ss[i + 1][2])
				if d < ans:
					xx = ss[i][2] + 2
					yy = ss[i + 1][2] + 1
					ans = d
		if ans == inf:
			print(-1)
		else:
			print(xx, yy)
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
main()


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	mi = 10 ** 12
	ind1 = 0
	ind2 = 0
	su = 0
	d[0] = 0

	def check(k):
		if k == 'L':
			return 1
		elif k == 'R':
			return -1
		elif k == 'U':
			return 10 ** 6
		else:
			return -10 ** 6
	for i in range(n):
		su += check(s[i])
		if d.get(su, -1) == -1:
			d[su] = i + 1
		elif i + 1 - d[su] < mi:
			ind1 = d[su]
			ind2 = i + 1
			mi = i - d[su]
			d[su] = i + 1
		else:
			d[su] = i + 1
	if mi == 10 ** 12:
		print(-1)
	else:
		print(ind1 + 1, ind2)


from sys import stdin
input = stdin.readline
q = int(input())
N = 2342379478943
for rwwe in range(q):
	n = int(input())
	s = input()
	k = []
	for i in range(n):
		if s[i] == 'L':
			k.append(1)
		if s[i] == 'R':
			k.append(-1)
		if s[i] == 'U':
			k.append(N)
		if s[i] == 'D':
			k.append(-N)
	pref = [0] * (n + 1)
	for i in range(1, n + 1):
		pref[i] = pref[i - 1] + k[i - 1]
	d = {}
	for i in pref:
		d[i] = []
	for i in range(len(pref)):
		d[pref[i]].append(i)
	best = 10000000000
	odp = ['a', 'a']
	for i in d:
		if len(d[i]) < 2:
			continue
		else:
			for j in range(1, len(d[i])):
				if d[i][j] - d[i][j - 1] < best:
					best = d[i][j] - d[i][j - 1]
					odp = [d[i][j - 1] + 1, d[i][j]]
	if odp != ['a', 'a']:
		print(*odp)
	else:
		print(-1)


import math, sys
from collections import Counter, defaultdict, deque
from sys import stdin, stdout
input = stdin.readline
lili = lambda : list(map(int, sys.stdin.readlines()))
li = lambda : list(map(int, input().split()))
I = lambda : int(input())
S = lambda : input().strip()
mod = 1000000007
for i in range(I()):
	n = I()
	a = S()
	d = defaultdict(int)
	(p, q, r, s) = (0, 0, 0, 0)
	m = 2 * 100000 + 5
	(x, y) = (-1, -1)
	d[0, 0] = -1
	for i in range(0, n):
		if a[i] == 'L':
			p -= 1
		elif a[i] == 'R':
			p += 1
		elif a[i] == 'U':
			q += 1
		elif a[i] == 'D':
			q -= 1
		if (p, q) in d:
			k = d[p, q]
			if i - k < m:
				(x, y) = (k + 1, i)
				m = i - k
			d[p, q] = i
		else:
			d[p, q] = i
	if x != -1:
		print(x + 1, y + 1)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	x = 0
	y = 0
	d[x, y] = [0]
	p1 = -1
	p2 = -1
	i = 0
	for c in s:
		i += 1
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'D':
			y -= 1
		else:
			y += 1
		try:
			d[x, y].append(i)
			if p1 == -1:
				p2 = d[x, y][-1]
				p1 = d[x, y][-2]
			if d[x, y][-1] - d[x, y][-2] < p2 - p1:
				p2 = d[x, y][-1]
				p1 = d[x, y][-2]
		except:
			d[x, y] = [i]
	if p1 != -1:
		print(p1 + 1, p2)
	else:
		print(-1)


for _ in range(int(input())):
	n = int(input())
	a = input()
	d = {(0, 0): -1}
	(x, y, ans) = (0, 0, 10 ** 9)
	for i in range(n):
		x += int(a[i] == 'R')
		x -= int(a[i] == 'L')
		y += int(a[i] == 'U')
		y -= int(a[i] == 'D')
		if (x, y) in d and ans > i - d[x, y]:
			ans = i - d[x, y]
			(p, q) = (d[x, y] + 1, i)
		d[x, y] = i
	if ans != 10 ** 9:
		print(p + 1, q + 1)
	else:
		print(-1)


N = int(input())
for _ in range(N):
	m = int(input())
	s = input()
	poz = {}
	poz[0, 0] = 0
	x = y = 0
	u = v = -1
	minimum = 2 * m
	for i in range(len(s)):
		if s[i] == 'R':
			x = x + 1
		elif s[i] == 'L':
			x = x - 1
		elif s[i] == 'U':
			y = y + 1
		elif s[i] == 'D':
			y = y - 1
		if (x, y) in poz.keys():
			dist = i - poz[x, y] + 1
			if dist < minimum:
				minimum = dist
				u = poz[x, y]
				v = i
			poz[x, y] = i + 1
		else:
			poz[x, y] = i + 1
	if u == -1:
		print(-1)
	else:
		print(u + 1, v + 1)


def fun1(n):
	h = [0, 0]
	cur = [0, 0]
	tmp = [0, 0]
	for i in range(len(n)):
		if n[i] == 'L':
			cur[0] += -1
		if n[i] == 'R':
			cur[0] += 1
		if n[i] == 'U':
			cur[1] += 1
		if n[i] == 'D':
			cur[1] += -1
		for e in range(0, len(h), 2):
			if cur[0] == h[e]:
				if cur[1] == h[e + 1]:
					if tmp[1] - tmp[0] > i - e // 2 or not tmp[1] - tmp[0]:
						tmp = [e // 2 + 1, i + 1]
		h += cur
	return tmp if tmp[1] - tmp[0] else [-1]

def fun(n):
	cur = [0, 0]
	dct = {(0, 0): [-1]}
	tmp = [0, 0, 0]
	for i in range(len(n)):
		if n[i] == 'L':
			cur[0] += -1
		if n[i] == 'R':
			cur[0] += 1
		if n[i] == 'U':
			cur[1] += 1
		if n[i] == 'D':
			cur[1] += -1
		if tuple(cur) in dct:
			dct[tuple(cur)] += [i]
		else:
			dct[tuple(cur)] = [i]
	min = [0, 0]
	for element in dct.values():
		if len(element) > 1:
			for i in range(len(element) - 1):
				if min[1] - min[0] > element[i + 1] - element[i] or min[1] == min[0]:
					min[0] = element[i] + 2
					min[1] = element[i + 1] + 1
	return min if min[1] - min[0] else [-1]
for _ in range(int(input())):
	input()
	n = input()
	for i in fun(n):
		print(i, end=' ')
	print()


import sys
input = sys.stdin.readline

def main():
	t = int(input())
	for testcase in range(t):
		n = int(input())
		s = list(input())
		p = [10 ** 21]
		dg = 10 ** 7
		last = 10 ** 14
		for i in range(n):
			if s[i] == 'L':
				last += 1
				p.append(last * dg + i + 1)
			elif s[i] == 'R':
				last -= 1
				p.append(last * dg + i + 1)
			elif s[i] == 'U':
				last += dg
				p.append(last * dg + i + 1)
			else:
				last -= dg
				p.append(last * dg + i + 1)
		p.sort()
		res1 = -1
		res2 = -1
		sub = 10 ** 6
		for i in range(n):
			if p[i] // 10 ** 6 == p[i + 1] // 10 ** 6:
				tmp1 = p[i] % 10 ** 6
				tmp2 = p[i + 1] % 10 ** 6
				if tmp2 - tmp1 < sub:
					res1 = tmp1
					res2 = tmp2
					sub = tmp2 - tmp1
		if res1 == -1:
			print(-1)
		else:
			print(res1 + 1, res2)
main()


for _ in range(int(input())):
	n = int(input())
	s = list(input())
	d1 = {}
	d1[0, 0] = [0]
	(x, y) = (0, 0)
	i = 1
	for c in s:
		if c == 'L':
			x -= 1
		if c == 'R':
			x += 1
		if c == 'U':
			y += 1
		if c == 'D':
			y -= 1
		if (x, y) in d1:
			d1[x, y].append(i)
		else:
			d1[x, y] = [i]
		i += 1
	answer = -1
	answer_coord = [0, 0]
	for x in d1:
		if len(d1[x]) > 1:
			d1[x].sort()
			for i in range(len(d1[x]) - 1):
				if answer == -1:
					answer = d1[x][i + 1] - d1[x][i]
					answer_coord = [d1[x][i + 1], d1[x][i]]
				elif d1[x][i + 1] - d1[x][i] < answer:
					answer = d1[x][i + 1] - d1[x][i]
					answer_coord = [d1[x][i + 1], d1[x][i]]
	a = answer_coord[1]
	b = answer_coord[0]
	if answer != -1:
		print(a + 1, b)
	else:
		print(-1)


def point(x, y):
	return '(' + str(x) + ',' + str(y) + ')'
t = int(input())
for i in range(t):
	dict = {}
	min = 1000000000
	len = 0
	start = 0
	end = 0
	x = 0
	y = 0
	temp = point(x, y)
	step = 1
	dict[temp] = [1]
	num = int(input())
	path = input()
	for i in range(num):
		if path[i] == 'L':
			x -= 1
		if path[i] == 'R':
			x += 1
		if path[i] == 'U':
			y += 1
		if path[i] == 'D':
			y -= 1
		step += 1
		temp = point(x, y)
		if temp in dict:
			len = step - dict[temp][-1] + 1
			if len < min:
				min = len
				start = dict[temp][-1]
				end = step - 1
			dict[temp].append(step)
		else:
			dict[temp] = [step]
	if min == 1000000000:
		print(-1)
	else:
		print(start, end)


import sys

def getN():
	return int(input())

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

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

def getArray(intn):
	return [int(input()) for i in range(intn)]

def input():
	return sys.stdin.readline().rstrip()
for _ in range(getN()):
	n = getN()
	s = input()
	coords = dict()
	coords[0, 0] = 1
	x = y = 0
	pred = 10 ** 9
	ans = -1
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'D':
			y -= 1
		else:
			y += 1
		if (x, y) in coords:
			l = coords[x, y]
			r = i + 1
			if pred > r - l:
				ans = f'{l} {r}'
				pred = r - l
		coords[x, y] = i + 2
	print(ans)


from sys import stdin
input = stdin.readline
for xoxo in range(1):
	for _ in range(int(input())):
		a = []
		n = int(input())
		s = input()
		x = 0
		y = 0
		d = {(0, 0): 0}
		for i in range(n):
			if s[i] == 'L':
				x -= 1
			elif s[i] == 'R':
				x += 1
			elif s[i] == 'U':
				y += 1
			else:
				y -= 1
			if (x, y) not in d:
				d[x, y] = i + 1
			else:
				j = d.get((x, y))
				a.append([i - j + 1, j, i])
				d1 = {(x, y): i + 1}
				d.update(d1)
		a.sort()
		if len(a) == 0:
			print(-1)
		else:
			print(a[0][1] + 1, a[0][2] + 1)


def mi():
	return map(int, input().split())
from collections import defaultdict
for _ in range(int(input())):
	l = int(input())
	s = list(input())
	i = 0
	(cx, cy) = (0, 0)
	sxx = defaultdict(int)
	ind = -1
	ans = 10 ** 10
	sxx[0, 0] = 0
	while i < l:
		if s[i] == 'L':
			cx -= 1
		elif s[i] == 'R':
			cx += 1
		elif s[i] == 'U':
			cy += 1
		else:
			cy -= 1
		if (cx, cy) == (0, 0) or sxx[cx, cy]:
			if i - sxx[cx, cy] + 1 < ans:
				ans = i - sxx[cx, cy] + 1
				ind = i
		sxx[cx, cy] = i + 1
		i += 1
	if ans == 10 ** 10 or ans <= 1:
		print(-1)
	else:
		print(ind - ans + 2, ind + 1)


import sys
input = sys.stdin.readline
from collections import defaultdict
t = int(input())
for tests in range(t):
	n = int(input())
	S = input().strip()
	ANS = 1 << 31
	D = defaultdict(list)
	NOW = [0, 0]
	TIME = 0
	D[tuple(NOW)].append(TIME)
	TIME += 1
	for s in S:
		if s == 'U':
			NOW[0] += 1
		elif s == 'D':
			NOW[0] -= 1
		elif s == 'R':
			NOW[1] += 1
		else:
			NOW[1] -= 1
		D[tuple(NOW)].append(TIME)
		TIME += 1
		if len(D[tuple(NOW)]) > 1 and ANS > D[tuple(NOW)][-1] - D[tuple(NOW)][-2]:
			ANS = D[tuple(NOW)][-1] - D[tuple(NOW)][-2]
			ANSX = (D[tuple(NOW)][-2] + 1, D[tuple(NOW)][-1])
	if ANS == 1 << 31:
		print(-1)
	else:
		print(*ANSX)


t = int(input())
inputarrs = list()
for r in range(t):
	input()
	inputarrs.append(input())
ud = 0
lr = 0
ans = {}
for i in inputarrs:
	ind = 0
	ans[ud, lr] = [ind]
	for char in i:
		ind += 1
		if char == 'U':
			ud += 1
		elif char == 'D':
			ud -= 1
		elif char == 'L':
			lr -= 1
		elif char == 'R':
			lr += 1
		if (ud, lr) in ans:
			ans[ud, lr].append(ind)
		else:
			ans[ud, lr] = [ind]
	smallest = 9999999999999999999999999
	smallestKeys = None
	for key in ans:
		valarr = ans[key]
		start = valarr[0]
		for r in range(1, len(valarr)):
			end = valarr[r]
			if end - start < smallest:
				smallest = end - start
				smallestKeys = (start, end)
			start = end
	ans.clear()
	if smallestKeys:
		print(str(smallestKeys[0] + 1) + ' ' + str(smallestKeys[1]))
	else:
		print(-1)


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	lr = [0]
	ud = [0]
	d = {}
	min = [float('inf'), -1, -1]
	for i in range(n):
		if s[i] == 'L':
			now = [-1, 0]
		elif s[i] == 'R':
			now = [1, 0]
		elif s[i] == 'U':
			now = [0, 1]
		elif s[i] == 'D':
			now = [0, -1]
		lr.append(lr[i] + now[0])
		ud.append(ud[i] + now[1])
	for i in range(n + 1):
		if (lr[i], ud[i]) in d:
			if min[0] > i - d[lr[i], ud[i]]:
				min = [i - d[lr[i], ud[i]], d[lr[i], ud[i]], i]
		d[lr[i], ud[i]] = i
	if min[1] != -1:
		print(min[1] + 1, min[2])
	else:
		print(-1)


for i in range(int(input())):
	n = int(input())
	s = input()
	di = {}
	po = [0, 0]
	ma = 200001
	re = le = 0
	cy = 0
	di[0, 0] = 0
	for j in range(1, n + 1):
		if s[j - 1] == 'L':
			po[0] -= 1
		if s[j - 1] == 'R':
			po[0] += 1
		if s[j - 1] == 'U':
			po[1] += 1
		if s[j - 1] == 'D':
			po[1] -= 1
		tu = tuple(po)
		if tu in di.keys():
			a = j - di[tu]
			if a < ma:
				ma = a
				le = di[tu]
				re = j
			di[tu] = j
			cy = 1
		else:
			di[tu] = j
	if cy == 1:
		print(le + 1, re)
	else:
		print(-1)


def main():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		ans = []
		for i in range(1, n):
			if s[i] == 'L' and s[i - 1] == 'R':
				ans = [i, i + 1]
				break
			if s[i] == 'R' and s[i - 1] == 'L':
				ans = [i, i + 1]
				break
			if s[i] == 'U' and s[i - 1] == 'D':
				ans = [i, i + 1]
				break
			if s[i] == 'D' and s[i - 1] == 'U':
				ans = [i, i + 1]
				break
		if not ans:
			ok = ['LURD', 'LDRU', 'RULD', 'RDUL', 'DLUR', 'DRUL', 'URDL', 'ULDR']
			for i in range(4, n + 1):
				if s[i - 4:i] in ok:
					ans = [i - 3, i]
					break
			if not ans:
				L = n + 1
				p = (0, 0)
				d = {p: 1}
				(x, y) = (0, 0)
				for j in range(n):
					if s[j] == 'U':
						y += 1
					if s[j] == 'R':
						x += 1
					if s[j] == 'D':
						y -= 1
					if s[j] == 'L':
						x -= 1
					if (x, y) in d:
						if j - d[x, y] < L:
							ans = [d[x, y], j + 1]
							L = j - d[x, y]
					d[x, y] = j + 2
		if ans:
			print(*ans)
		else:
			print(-1)
main()


import sys

def fastio():
	from io import StringIO
	from atexit import register
	global input
	sys.stdin = StringIO(sys.stdin.read())
	input = lambda : sys.stdin.readline().rstrip('\r\n')
	sys.stdout = StringIO()
	register(lambda : sys.__stdout__.write(sys.stdout.getvalue()))
fastio()

def debug(*var, sep=' ', end='\n'):
	print(*var, file=sys.stderr, end=end, sep=sep)
INF = 10 ** 20
MOD = 10 ** 9 + 7
I = lambda : list(map(int, input().split()))
from math import gcd
from math import ceil
from collections import defaultdict as dd, Counter
from bisect import bisect_left as bl, bisect_right as br
(t,) = I()
while t:
	t -= 1
	(n,) = I()
	s = input()
	state = dd(lambda : -1)
	(l, u) = (0, 0)
	ans = INF
	res = []
	state[0, 0] = 1
	for i in range(n):
		if s[i] == 'L':
			l += 1
		elif s[i] == 'R':
			l -= 1
		if s[i] == 'U':
			u += 1
		elif s[i] == 'D':
			u -= 1
		if state[l, u] != -1 and i - state[l, u] + 2 < ans:
			ans = i - state[l, u] + 2
			res = [state[l, u], i + 1]
		state[l, u] = i + 2
	if ans == INF:
		print(-1)
	else:
		print(*res)


t = int(input())
while t:
	save = (0, 0)
	t -= 1
	n = int(input())
	s = input()
	(x, y, d, shrt) = (0, 0, {}, 1000000000)
	d[x, y] = 0
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d.keys():
			if shrt > i + 1 - d[x, y]:
				shrt = i + 1 - d[x, y]
				save = (d[x, y] + 1, d[x, y] + shrt)
				if shrt == 2:
					break
		d[x, y] = i + 1
	print(*save) if save != (0, 0) else print(-1)


T = int(input())
for t in range(T):
	n = int(input())
	s = input()
	path = {}
	c1 = (0, 0)
	co = [0, 0]
	m = 1000000
	M = [-1, -1]
	i = 1
	for c in s:
		path[c1] = i
		if c == 'L':
			co[0] -= 1
		elif c == 'R':
			co[0] += 1
		elif c == 'U':
			co[1] -= 1
		else:
			co[1] += 1
		c1 = (co[0], co[1])
		if c1 in path.keys():
			mi = i - path[c1]
			if mi < m:
				m = mi
				M[0] = path[c1]
				M[1] = i
				path[c1] = i
		i += 1
	if M[0] == -1 or M[1] == -1:
		print(-1)
	else:
		print(M[0], M[1])


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	set_ = set()
	set_.add((0, 0))
	dict_ = {(0, 0): 0}
	x = 0
	y = 0
	i = 0
	bull = True
	prob_ans = [0, 0]
	while i < n:
		elem = s[i]
		if elem == 'L':
			y -= 1
		elif elem == 'R':
			y += 1
		elif elem == 'D':
			x -= 1
		else:
			x += 1
		mas = (x, y)
		if mas in set_:
			bull = False
			j = dict_.get(mas)
			dict_[mas] = i + 1
			if prob_ans == [0, 0]:
				prob_ans = [j + 1, i + 1]
			elif prob_ans[1] - prob_ans[0] + 1 > i + 1 - (j + 1) + 1:
				prob_ans = [j + 1, i + 1]
		else:
			set_.add(mas)
			dict_[mas] = i + 1
		i += 1
	if bull:
		print(-1)
	else:
		print(prob_ans[0], prob_ans[1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	seen = {(0, 0): [0]}
	ans = []
	for (i, c) in enumerate(s):
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		elif c == 'D':
			y -= 1
		if (x, y) in seen:
			a = (max(seen[x, y]) + 1, i + 1)
			ans.append(a)
			if a[1] - a[0] == 1:
				break
			seen[x, y].append(i + 1)
		else:
			seen[x, y] = [i + 1]
	if ans:
		best = n + 1
		p = None
		for a in ans:
			dist = a[1] - a[0]
			if dist < best:
				best = dist
				p = a
		print(p[0], p[1])
	else:
		print('-1')


import sys
input = sys.stdin.readline
t = int(input())
for i in range(t):
	n = int(input())
	s = input().rstrip()
	d = {}
	x = 0
	y = 0
	d['0 0'] = 0
	ans = 10 ** 9
	ans_s = ''
	for (i, c) in enumerate(s, start=1):
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		else:
			y -= 1
		p = '{} {}'.format(x, y)
		try:
			if i - d[p] + 1 < ans:
				ans = i - d[p] + 1
				ans_s = '{} {}'.format(d[p] + 1, i)
				d[p] = i
			else:
				d[p] = i
		except:
			d[p] = i
	if ans == 10 ** 9:
		print(-1)
	else:
		print(ans_s)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	d = {(0, 0): 0}
	(x, y) = (0, 0)
	time = 0
	ans = [-1]
	for i in s:
		time += 1
		if i == 'D':
			y -= 1
		elif i == 'U':
			y += 1
		elif i == 'L':
			x -= 1
		else:
			x += 1
		if (x, y) not in d:
			pass
		elif len(ans) == 1 or ans[1] - ans[0] > time - d[x, y]:
			ans = [d[x, y] + 1, time]
		d[x, y] = time
	print(*ans)


class Pair:

	def __init__(self, l, r):
		self.l = l
		self.r = r
		self.w = r - l

class Position:

	def __init__(self, x, y):
		self.x = x
		self.y = y
		self.str = '{0}_{1}'.format(x, y)

def solve(N, path):
	(x, y) = (0, 0)
	result = Pair(-2000000, 2000000)
	map = {}
	map[Position(x, y).str] = 0
	for i in range(0, N, 1):
		x -= 1 if path[i] == 'L' else 0
		x += 1 if path[i] == 'R' else 0
		y += 1 if path[i] == 'U' else 0
		y -= 1 if path[i] == 'D' else 0
		pair = Position(x, y).str
		if pair in map:
			res = Pair(map[pair], i + 1)
			if res.w < result.w:
				result = res
		map[pair] = i + 1
	return result
T = int(input())
for t in range(0, T, 1):
	N = int(input())
	path = input()
	result = solve(N, path)
	if result.w == 4000000:
		print(-1)
	else:
		print(result.l + 1, result.r)


from sys import stdin
from collections import defaultdict
input = stdin.readline
t = int(input())

def getAns(n, s):
	d = defaultdict()
	currPos = 0
	currMin = n + 1
	currMins = -1
	d[0] = 0
	for i in range(n):
		if s[i] == 'L':
			currPos -= n
		elif s[i] == 'R':
			currPos += n
		elif s[i] == 'U':
			currPos += 1
		else:
			currPos -= 1
		if d.get(currPos) != None:
			if i + 1 - d[currPos] < currMin:
				currMin = i + 1 - d[currPos]
				currMins = [d[currPos], i + 1]
		d[currPos] = i + 1
	if currMins == -1:
		print(-1)
		return
	else:
		currMins[0] += 1
		print(*currMins)
		return
for _ in range(t):
	n = int(input())
	s = list(input())
	getAns(n, s)


from collections import *
import sys
import math

def ri():
	return int(input())

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

def move(letter, pos):
	(x, y) = pos
	if letter == 'R':
		x += 1
	elif letter == 'L':
		x -= 1
	elif letter == 'U':
		y += 1
	elif letter == 'D':
		y -= 1
	return (x, y)
t = ri()
for _ in range(t):
	n = ri()
	s = input()
	d = dict()
	pos = (0, 0)
	d[pos] = 0
	ans = 10 ** 9
	disp = []
	for i in range(1, len(s) + 1):
		pos = move(s[i - 1], pos)
		if pos not in d.keys():
			d[pos] = i
		else:
			if i - d[pos] < ans:
				ans = i - d[pos]
				disp = [d[pos] + 1, i]
			d[pos] = i
	if ans == 10 ** 9:
		print(-1)
	else:
		print(*disp)


MOD = 1000000007
MOD2 = 998244353
ii = lambda : int(input())
si = lambda : input()
dgl = lambda : list(map(int, input()))
f = lambda : map(int, input().split())
il = lambda : list(map(int, input().split()))
ls = lambda : list(input())
for _ in range(ii()):
	n = ii()
	s = si()
	d = dict()
	d['0a0'] = 0
	(x, y) = (0, 0)
	(l, r) = (-1, -1)
	mn = 1000000000000
	for i in range(1, n + 1):
		if s[i - 1] == 'U':
			y += 1
		elif s[i - 1] == 'D':
			y -= 1
		elif s[i - 1] == 'L':
			x -= 1
		else:
			x += 1
		t = str(x) + 'a' + str(y)
		if t in d:
			if i - d[t] < mn:
				mn = i - d[t]
				l = d[t] + 1
				r = i
		d[t] = i
	if l == -1 and r == -1:
		print(-1)
	else:
		print(l, r)


def r(t=int):
	return list(map(t, input().split()))

def ri(t=int):
	return t(input())

def cd(it):
	ret_val = dict()
	for v in it:
		ret_val[v] = ret_val.get(v, 0) + 1
	return ret_val
for _ in range(ri()):
	n = ri()
	a = input()
	c = [0, 0]
	d = {(0, 0): -1}
	ans = [-2, n]
	for (i, ai) in enumerate(a):
		if ai == 'L':
			c[0] -= 1
		elif ai == 'R':
			c[0] += 1
		elif ai == 'U':
			c[1] += 1
		elif ai == 'D':
			c[1] -= 1
		cp = tuple(c)
		if cp in d:
			diff = ans[1] - ans[0]
			if diff > i - d[cp]:
				ans = [d[cp], i]
		d[cp] = i
	if ans[0] == -2:
		print(-1)
	else:
		print(ans[0] + 2, ans[1] + 1)


t = int(input())
for loop in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	dic = {}
	dic[0, 0] = -1
	ansl = float('-inf')
	ansr = float('inf')
	for (i, S) in enumerate(s):
		if S == 'L':
			x -= 1
		elif S == 'R':
			x += 1
		elif S == 'U':
			y += 1
		elif S == 'D':
			y -= 1
		if (x, y) in dic:
			nowl = dic[x, y]
			nowr = i
			if nowr - nowl < ansr - ansl:
				ansl = nowl
				ansr = nowr
		dic[x, y] = i
	if ansr == float('inf'):
		print(-1)
	else:
		print(ansl + 2, ansr + 1)


from sys import stdin, stdout
input = stdin.readline

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

def ii():
	return int(input())

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

def ins():
	return input()[:-1]
for _ in range(ii()):
	n = ii()
	s = ins()
	x = 0
	y = 0
	dic = {(0, 0): -1}
	mi = float('inf')
	mi_x = 0
	mi_y = 0
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if (x, y) in dic:
			a = dic[x, y] + 1
			b = i
			if b - a + 1 < mi:
				mi = b - a + 1
				mi_x = a
				mi_y = b
		dic[x, y] = i
	if mi == float('inf'):
		print(-1)
	else:
		print(mi_x + 1, mi_y + 1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	t = (0, 0)
	d[t] = [0]
	r = 0
	u = 0
	dist = float('inf')
	si = 0
	ei = 0
	for i in range(n):
		if s[i] == 'R':
			r += 1
		elif s[i] == 'L':
			r -= 1
		elif s[i] == 'U':
			u += 1
		else:
			u -= 1
		t = (r, u)
		if d.get(t) == None:
			d[t] = [i + 1]
		else:
			prev = d[t][-1]
			d[t].append(i + 1)
			if dist > i + 1 - prev:
				dist = i + 1 - prev
				si = prev + 1
				ei = i + 1
	if dist == float('inf'):
		print(-1)
	else:
		print(si, ei)


for _ in [0] * int(input()):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	dkt = {(0, 0): 1}
	(l, r) = (0, len(s) ** 2)
	for tmpo in range(n):
		if s[tmpo] == 'L':
			x -= 1
		if s[tmpo] == 'R':
			x += 1
		if s[tmpo] == 'U':
			y += 1
		if s[tmpo] == 'D':
			y -= 1
		if (x, y) in dkt.keys():
			if r - l > tmpo + 1 - dkt[x, y]:
				(l, r) = (dkt[x, y], tmpo + 1)
			dkt[x, y] = tmpo + 2
		else:
			dkt[x, y] = tmpo + 2
	if l == 0 and r == len(s) ** 2:
		print(-1)
	else:
		print(l, r)


for _ in range(int(input())):
	n = int(input())
	(x, y) = (0, 0)
	coord = {(0, 0): 0}
	from heapq import heappush, heappop
	h = []
	for (i, ch) in enumerate(input()):
		if ch == 'L':
			x -= 1
		elif ch == 'R':
			x += 1
		elif ch == 'D':
			y -= 1
		else:
			y += 1
		if (x, y) in coord.keys():
			heappush(h, (i - coord[x, y], (coord[x, y], i)))
		coord[x, y] = i + 1
	if h:
		(dist, coord) = heappop(h)
		print(coord[0] + 1, coord[1] + 1)
	else:
		print(-1)


def insertpos(pos, i):
	if pos in robot.keys():
		robot[pos].append(i)
		robot[pos][0] += 1
	else:
		robot[pos] = [1, i]

def solve(robot):
	min_diff = 1000000
	ans = -1
	for value in robot.values():
		if value[0] >= 2:
			for i in range(1, len(value) - 1):
				diff = value[i + 1] - value[i]
				if diff < min_diff:
					min_diff = diff
					ans = '{} {}'.format(value[i] + 1, value[i + 1])
	return ans
t = int(input())
for __ in range(t):
	n = int(input())
	path = input()
	pos = (0, 0)
	robot = {(0, 0): [1, 0]}
	i = 1
	for step in path:
		if step == 'U':
			pos = (pos[0], pos[1] + 1)
			insertpos(pos, i)
		elif step == 'D':
			pos = (pos[0], pos[1] - 1)
			insertpos(pos, i)
		elif step == 'R':
			pos = (pos[0] + 1, pos[1])
			insertpos(pos, i)
		elif step == 'L':
			pos = (pos[0] - 1, pos[1])
			insertpos(pos, i)
		i += 1
	print(solve(robot))


from sys import stdin
from collections import deque
from math import sqrt, floor, ceil, log, log2, log10, pi, gcd, sin, cos, asin

def ii():
	return int(stdin.readline())

def fi():
	return float(stdin.readline())

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

def fmi():
	return map(float, stdin.readline().split())

def li():
	return list(mi())

def lsi():
	x = list(stdin.readline())
	x.pop()
	return x

def si():
	return stdin.readline()

def sieve(x):
	a = [True] * (x + 1)
	sq = floor(sqrt(x))
	for i in range(3, sq + 1, 2):
		if a[i]:
			for j in range(i * i, x + 1, i):
				a[j] = False
	if x > 1:
		p = [2]
	else:
		p = []
	for i in range(3, x + 1, 2):
		if a[i]:
			p.append(i)
	return p
res = ['YES', 'NO']
for _ in range(ii()):
	d = {(0, 0): 0}
	x = y = 0
	n = ii()
	a = lsi()
	c = 1
	ds = 300003
	(l, r) = (0, 300003)
	for i in a:
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) not in d:
			d[x, y] = c
		else:
			if c - d[x, y] < ds:
				l = d[x, y] + 1
				r = c
				ds = c - d[x, y]
			d[x, y] = c
		c += 1
	if ds == 300003:
		print(-1)
	else:
		print(l, r)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	ans = 10 ** 20
	l = -1
	r = -1
	visited = {}
	visited[0, 0] = 0
	x = 0
	y = 0
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) not in visited:
			visited[x, y] = i + 1
		else:
			if ans > i - visited[x, y]:
				ans = i - visited[x, y]
				l = visited[x, y]
				r = i
			visited[x, y] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


import math
from sys import stdin, stdout
T = int(stdin.readline())
for i in range(T):
	N = int(stdin.readline())
	S = stdin.readline()
	dict = {}
	aa = 1
	ab = N
	ans = N + 1
	dict[1] = 1
	curr = 1
	k = 200000
	ind = 1
	for j in range(N):
		i = S[j]
		if i == 'L':
			curr -= 1
		elif i == 'U':
			curr += k
		elif i == 'R':
			curr += 1
		else:
			curr -= k
		if curr in dict:
			st = dict[curr]
			if ind - st + 1 < ans:
				ans = ind - st + 1
				aa = st
				ab = ind
		dict[curr] = ind + 1
		ind += 1
	if ans == N + 1:
		print(-1)
	else:
		print(str(aa) + ' ' + str(ab))


t = int(input())
for i in range(t):
	s = int(input())
	a = input()
	s1 = {(0, 0): 0}
	pos = 0
	pos1 = 0
	m = s + 1
	st = 0
	for j in range(s):
		if a[j] == 'L':
			pos1 += 1
		elif a[j] == 'R':
			pos1 -= 1
		elif a[j] == 'U':
			pos += 1
		else:
			pos -= 1
		if (pos, pos1) in s1.keys():
			if m > j + 1 - s1[pos, pos1]:
				m = j + 1 - s1[pos, pos1]
				st = j + 1
		s1[pos, pos1] = j + 1
	if m == s + 1:
		print(-1)
	else:
		print(st - m + 1, st)


t = int(input())
for _ in range(t):
	n = int(input())
	a = input()
	b = {'L': -2, 'R': +2, 'U': +1, 'D': -1}
	(c, d) = ([0] * n, [0] * n)
	for i in range(n):
		if a[i] == 'L' or a[i] == 'R':
			if a[i] == 'L':
				c[i] = 1
			if a[i] == 'R':
				c[i] = -1
		else:
			c[i] = 0
		if a[i] == 'U' or a[i] == 'D':
			if a[i] == 'U':
				d[i] = 1
			if a[i] == 'D':
				d[i] = -1
		else:
			d[i] = 0
	for i in range(1, n):
		c[i] = c[i - 1] + c[i]
	for i in range(1, n):
		d[i] = d[i - 1] + d[i]
	e = {}
	e[0, 0] = [0]
	for i in range(n):
		if (c[i], d[i]) in e:
			e[c[i], d[i]].append(i + 1)
		else:
			e[c[i], d[i]] = [i + 1]
	l = float('inf')
	for i in e:
		p = len(e[i])
		k = e[i]
		if p == 1:
			continue
		else:
			for j in range(p - 1):
				if k[j + 1] - k[j] < l:
					(x, y) = (k[j] + 1, k[j + 1])
					l = k[j + 1] - k[j]
	if l == float('inf'):
		print(-1)
	else:
		print(x, y)


for _ in range(int(input())):
	n = int(input())
	ar = list(input())
	(left, right) = (0, 0)
	kek = [[0, 0, 0]]
	for i in range(n):
		elem = ar[i]
		if elem == 'L':
			left -= 1
		elif elem == 'R':
			left += 1
		elif elem == 'U':
			right += 1
		else:
			right -= 1
		kek.append([left, right, i + 1])
	kek.sort()
	ans = 10 ** 9
	(a, b) = (-1, -1)
	for i in range(n + 1):
		if kek[i][0] == kek[i - 1][0] and kek[i][1] == kek[i - 1][1] and (kek[i][2] - kek[i - 1][2] < ans):
			ans = kek[i][2] - kek[i - 1][2]
			(a, b) = (kek[i - 1][2] + 1, kek[i][2])
	if a == b == -1:
		print(-1)
	else:
		print(a, b)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	dictn = {}
	answer = 9999999999
	(x, y) = (0, 0)
	(i1, i2) = (-1, -1)
	dictn[x, y] = -1
	for i in range(n):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in dictn:
			df = i - dictn[x, y]
			if df < answer:
				answer = df
				i1 = dictn[x, y]
				i2 = i
		dictn[x, y] = i
	if answer == 9999999999:
		print(-1)
	else:
		print(i1 + 2, i2 + 1)


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

def num():
	return int(input())
from itertools import repeat
from math import inf
t = num()
for _ in repeat(None, t):
	n = num()
	s = input()
	q = {}
	(x, y) = (0, 0)
	q[0, 0] = -1
	ans = (-inf, inf)
	for (i, w) in enumerate(s):
		if w == 'L':
			x -= 1
		elif w == 'R':
			x += 1
		elif w == 'U':
			y += 1
		elif w == 'D':
			y -= 1
		if (x, y) in q and ans[1] - ans[0] > i - q[x, y]:
			ans = (q[x, y], i)
		q[x, y] = i
	if ans[0] == -inf:
		print(-1)
	else:
		print(ans[0] + 2, ans[1] + 1)


t = int(input())
for _ in range(t):
	m = {}
	x = 0
	y = 0
	m[x, y] = 0
	shortest = 9999999999999
	points = []
	input()
	s = input()
	c = 1
	for i in s:
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		if (x, y) in m:
			if c - m[x, y] + 1 < shortest:
				shortest = c - m[x, y] + 1
				points = [m[x, y] + 1, c]
		m[x, y] = c
		c += 1
	if len(points) == 0:
		print('-1')
	else:
		print(*points)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	res = [0, 0]
	c = {tuple(res): -1}
	mn = 10 ** 100
	z = []
	for j in range(n):
		if s[j] == 'U':
			res[1] -= 1
		elif s[j] == 'D':
			res[1] += 1
		elif s[j] == 'L':
			res[0] -= 1
		else:
			res[0] += 1
		if tuple(res) in c:
			if mn > j - c[tuple(res)]:
				mn = j - c[tuple(res)]
				z = [c[tuple(res)], j]
		c[tuple(res)] = j
	if mn != 10 ** 100:
		print(str(z[0] + 2) + ' ' + str(z[1] + 1))
	else:
		print(-1)


from sys import stdin
t = int(input())
dirr = {}
dirr['U'] = [0, -1]
dirr['D'] = [0, 1]
dirr['L'] = [-1, 0]
dirr['R'] = [1, 0]
for _ in range(t):
	n = int(input())
	s = stdin.readline().strip()
	best = float('inf')
	(l, r) = (0, 0)
	mp = {}
	(x, y) = (0, 0)
	mp[0, 0] = 0
	x += dirr[s[0]][0]
	y += dirr[s[0]][1]
	mp[x, y] = 1
	for i in range(1, n):
		x += dirr[s[i]][0]
		y += dirr[s[i]][1]
		if (x, y) not in mp:
			mp[x, y] = i + 1
		else:
			if i + 1 - mp[x, y] < best:
				l = mp[x, y]
				r = i
				best = r - l + 1
			mp[x, y] = i + 1
	if best >= float('inf'):
		print(-1)
	else:
		print(l + 1, r + 1)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()
from random import randint
from collections import defaultdict, deque

class Graph(object):

	def __init__(self, dic):
		self.dict = dic
		self.vertex = set()

	def addedge(self, a, b):
		if self.dict[a] == []:
			self.vertex.add(a)
		if b != None:
			self.dict[a].append(b)

	def con_com_util(self, i, unvisited, count, comp):
		for j in self.dict[i]:
			if j in unvisited:
				unvisited.remove(j)
				comp[count].append(j)
				comp = self.con_com_util(j, unvisited, count, comp)
		return comp

	def conn_components(self):
		unvisited = self.vertex.copy()
		count = 0
		comp = defaultdict(list)
		while unvisited:
			i = unvisited.pop()
			comp[count].append(i)
			comp = self.con_com_util(i, unvisited, count, comp)
			count += 1
		return (count, comp)

def countSetBits(n):
	count = 0
	while n:
		n &= n - 1
		count += 1
	return count

def g():
	return -1

def solve():
	n = int(inp())
	s = inp()
	d = defaultdict(g)
	d[0, 0] = 0
	ar = []
	cur = (0, 0)
	m = 999999999999999999
	for i in range(n):
		if s[i] == 'L':
			cur = (cur[0] - 1, cur[1])
		if s[i] == 'R':
			cur = (cur[0] + 1, cur[1])
		if s[i] == 'D':
			cur = (cur[0], cur[1] - 1)
		if s[i] == 'U':
			cur = (cur[0], cur[1] + 1)
		if d[cur] != -1:
			if i + 1 - d[cur] < m:
				m = i + 1 - d[cur]
				ans = (d[cur], i + 1)
			d[cur] = i + 1
		else:
			d[cur] = i + 1
	if m == 999999999999999999:
		print(-1)
	else:
		print(ans[0] + 1, ans[1])
testcase(int(inp()))


def solve(n, s):
	x = 0
	y = 0
	l = -n
	r = n
	N = 1000000000
	dp = {}
	dp[0] = 0
	for (i, d) in enumerate(s, start=1):
		if d == 'L':
			x += 1
		if d == 'R':
			x -= 1
		if d == 'U':
			y += 1
		if d == 'D':
			y -= 1
		try:
			j = dp[x * N + y] + 1
			if i - j < r - l:
				(l, r) = (j, i)
		except:
			pass
		dp[x * N + y] = i
	if l == -n and r == n:
		print('-1')
	else:
		print(l, r)

def main():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		solve(n, s)
main()


for i in range(int(input())):
	input()
	e = [i for i in input()]
	vm = 0
	hm = 0
	sp = {(0, 0): 0}
	s = 0
	ret = []
	m = 1000000
	for i in e:
		s += 1
		if i == 'L':
			hm -= 1
		elif i == 'R':
			hm += 1
		elif i == 'U':
			vm += 1
		else:
			vm -= 1
		if (vm, hm) in sp:
			sc = s - sp[vm, hm]
			if sc < m:
				m = sc
				ret = [sp[vm, hm], s]
		sp[vm, hm] = s
	if len(ret):
		print(ret[0] + 1, ret[1])
	else:
		print(-1)


t = int(input())
while t:
	t -= 1
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	mp = {(0, 0): 1}
	idx = 0
	(l, r) = (0, n)
	for i in s:
		idx += 1
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'U':
			y += 1
		else:
			y -= 1
		tmp = tuple([x, y])
		if tmp in mp:
			if r - l > idx - mp[tmp]:
				(l, r) = (mp[tmp], idx)
			mp[tmp] = idx + 1
		else:
			mp[tmp] = idx + 1
	if l > 0:
		print(l, r)
	else:
		print(-1)


reference = {'U': lambda netRight, netUp: (netRight, netUp + 1), 'D': lambda netRight, netUp: (netRight, netUp - 1), 'R': lambda netRight, netUp: (netRight + 1, netUp), 'L': lambda netRight, netUp: (netRight - 1, netUp)}
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	l = -1
	r = n + 1
	prevAtHere = dict()
	prevAtHere[0, 0] = -1
	x = y = 0
	for i in range(n):
		(x, y) = reference[s[i]](x, y)
		if (x, y) in prevAtHere.keys():
			if i - prevAtHere[x, y] < r - l:
				r = i
				l = prevAtHere[x, y]
		prevAtHere[x, y] = i
	if r == n + 1:
		print(-1)
	else:
		print('{} {}'.format(l + 2, r + 1))


from sys import stdin, stdout
input = stdin.readline
from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	s = input().strip()
	x_pos = 0
	y_pos = 0
	d = defaultdict(int)
	seen = set()
	ans = []
	ct = 10 ** 18
	d[0, 0] = 0
	seen.add((0, 0))
	for i in range(n):
		if s[i] == 'R':
			x_pos += 1
		elif s[i] == 'L':
			x_pos -= 1
		elif s[i] == 'U':
			y_pos += 1
		else:
			y_pos -= 1
		if (x_pos, y_pos) in seen and i - d[x_pos, y_pos] < ct:
			ct = 1 + i - d[x_pos, y_pos]
			ans = (d[x_pos, y_pos] + 1, i + 1)
		d[x_pos, y_pos] = i + 1
		seen.add((x_pos, y_pos))
	if ct == 10 ** 18:
		print(-1)
	else:
		print(*ans)


def binarySearch(arr, x):
	l = 0
	r = len(arr) - 1
	while l <= r:
		mid = (l + r) // 2
		if arr[mid] == x:
			return mid
		elif arr[mid] < x:
			l = mid + 1
		else:
			r = mid - 1
	return -1

def js(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] <= x:
			ans = m
			l = m + 1
		else:
			r = m - 1
	return ans

def jg(arr, x):
	l = 0
	r = len(arr) - 1
	ans = -1
	while l <= r:
		m = (l + r) // 2
		if arr[m] >= x:
			ans = m
			r = m - 1
		else:
			l = m + 1
	return ans
from math import *
for __ in range(int(input())):
	n = int(input())
	s = input()
	x = 0
	y = 0
	d = {(x, y): 0}
	ans = 999999
	rslt = 0
	aa = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if d.get((x, y)) != None:
			aa = 1
			if i - d.get((x, y)) < ans:
				r1 = d.get((x, y)) + 1
				r2 = i + 1
				ans = i - d.get((x, y))
		d[x, y] = i + 1
	if aa == 0:
		print(-1)
	else:
		print(r1, r2)


def f2(arr1, n):
	got = False
	arr = []
	for i in range(n):
		arr.append(arr1[i])
	x = y = 0
	D = {(0, 0): 0}
	a = [0, n + 2]
	for i in range(0, n):
		if arr[i] == 'L':
			x -= 1
		elif arr[i] == 'R':
			x += 1
		elif arr[i] == 'U':
			y += 1
		elif arr[i] == 'D':
			y -= 1
		if (x, y) in D.keys():
			got = True
			if a[1] - a[0] + 1 > i - D[x, y] + 1:
				a = [D[x, y] + 1, i + 1]
		D[x, y] = i + 1
	if got:
		return a
	else:
		return [-1]
t = int(input())
for w in range(t):
	n = int(input())
	arr1 = list(input().strip().split())
	arr1 = str(arr1[0])
	f = f2(arr1, n)
	print(*f)


out = []
for _ in range(int(input().strip())):
	n = int(input().strip())
	s = input().strip()
	cur = 0
	pre = [0]
	li = 10 ** 6
	for x in s:
		if x == 'L':
			pre.append(cur - 1)
		elif x == 'R':
			pre.append(cur + 1)
		elif x == 'U':
			pre.append(cur + li)
		else:
			pre.append(cur - li)
		cur = pre[-1]
	dic = {}
	ans = float('inf')
	sho = ''
	for i in range(len(pre)):
		if pre[i] in dic:
			diff = i - dic[pre[i]]
			if diff < ans:
				ans = diff
				sho = str(dic[pre[i]] + 1) + ' ' + str(i)
			dic[pre[i]] = i
		else:
			dic[pre[i]] = i
	if len(sho) == 0:
		out.append(str(-1))
	else:
		out.append(sho)
print('\n'.join(out))


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	A = {(0, 0): 1}
	cut = -1
	for i in range(n):
		l = n + 1
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		try:
			a = A[x, y]
			if i - a < n:
				cut = [a, i + 1]
				n = i - a
			A[x, y] = i + 2
		except KeyError:
			A[x, y] = i + 2
	if cut != -1:
		print(cut[0], cut[1])
	else:
		print(-1)


t = int(input())
for j in range(t):
	n = int(input())
	s = input()
	cx = 0
	cy = 0
	l = -1
	r = n
	point = dict()
	point[0, 0] = 0
	for i in range(len(s)):
		if s[i] == 'L':
			cx = cx - 1
		elif s[i] == 'R':
			cx = cx + 1
		elif s[i] == 'U':
			cy = cy + 1
		elif s[i] == 'D':
			cy = cy - 1
		if (cx, cy) not in point:
			point[cx, cy] = 0
		elif i - point[cx, cy] + 1 < r - l + 1:
			l = point[cx, cy]
			r = i
		point[cx, cy] = i + 1
	if l == -1 and r == n:
		print(-1)
	else:
		print(l + 1, r + 1)


from math import *
mod = 1000000007

def binpow(a, b):
	global mod
	if b == 1:
		return a % mod
	u = binpow(a, b // 2)
	if b % 2 == 0:
		return u * u % mod
	else:
		return u * u * a % mod
dic = {}

def ncr(n, r):
	if r > n - r:
		r = n - r
	if r == 0 and n == 0:
		return 1
	if r > n:
		return 0
	if n == r or r == 0:
		return 1
	if r == 1:
		return n
	key = str(n) + '|' + str(r)
	if key not in dic:
		dic[key] = ncr(n - 1, r - 1) + ncr(n - 1, r)
	return dic[key]
for _ in range(int(input())):
	dic = {}
	n = int(input())
	s = input()
	arr = [[0, 0] for i in range(n)]
	if s[0] == 'L':
		arr[0][0] += 1
	elif s[0] == 'R':
		arr[0][0] -= 1
	elif s[0] == 'U':
		arr[0][1] += 1
	else:
		arr[0][1] -= 1
	for i in range(1, n):
		if s[i] == 'L':
			arr[i][0] = arr[i - 1][0] + 1
			arr[i][1] = arr[i - 1][1]
		elif s[i] == 'R':
			arr[i][0] = arr[i - 1][0] - 1
			arr[i][1] = arr[i - 1][1]
		elif s[i] == 'U':
			arr[i][0] = arr[i - 1][0]
			arr[i][1] = arr[i - 1][1] + 1
		else:
			arr[i][0] = arr[i - 1][0]
			arr[i][1] = arr[i - 1][1] - 1
	dic['0|0'] = -1
	min = 100000000000
	l = 0
	r = 0
	b = False
	for i in range(n):
		key = str(arr[i][0]) + '|' + str(arr[i][1])
		if key in dic:
			b = True
			if i - dic[key] + 1 < min:
				l = dic[key]
				r = i
				min = i - dic[key] + 1
		dic[key] = i
	if b:
		print(l + 1 + 1, r + 1, sep=' ')
	else:
		print(-1)


a = input()
Case = int(a)
maxn = 2 * 100010
x = [0] * maxn
y = [0] * maxn
dict = {}
labels = {'U': [1, 0], 'D': [-1, 0], 'L': [0, -1], 'R': [0, 1]}
for T in range(Case):
	dict.clear()
	dict[0] = -1
	a = input()
	n = int(a)
	a = input()
	ansl = -1
	ansr = n
	for i in range(n):
		x[i] = x[i - 1] + labels[a[i]][0]
		y[i] = y[i - 1] + labels[a[i]][1]
		key = x[i] * maxn + y[i]
		if key in dict:
			if ansr - ansl > i - dict[key]:
				ansl = dict[key]
				ansr = i
		dict[key] = i
	if ansr - ansl > n:
		print('-1')
	else:
		print('{:d} {:d}'.format(ansl + 2, ansr + 1))


for _ in range(int(input())):
	n = int(input())
	string = input().strip()
	this = (0, 0)
	rec = {this}
	mini = 10000000000.0
	dick = dict()
	dick[this] = 0
	ans = [None, None]
	for i in range(n):
		if string[i] == 'L':
			this = (this[0] - 1, this[1])
		elif string[i] == 'R':
			this = (this[0] + 1, this[1])
		elif string[i] == 'U':
			this = (this[0], this[1] + 1)
		else:
			this = (this[0], this[1] - 1)
		if this not in rec:
			rec.add(this)
			dick[this] = i + 1
		else:
			diff = i + 1 - dick[this] + 1
			if diff < mini:
				mini = diff
				ans[0] = dick[this] + 1
				ans[1] = i + 1
				dick[this] = i + 1
			else:
				dick[this] = i + 1
	if ans[0] == None:
		print(-1)
	else:
		print(*ans)


import os
import sys
from io import BytesIO, IOBase
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')
(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
input = lambda : sys.stdin.readline().rstrip('\r\n')
for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	di = {}
	di['0,0'] = [0]
	exists = False
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		next = str(x) + ',' + str(y)
		if next not in di:
			di[next] = [i + 1]
		else:
			di[next] += [i + 1]
			exists = True
	if not exists:
		print(-1)
		continue
	ans = 10 ** 7
	anss = []
	for each in di:
		if len(di[each]) >= 2:
			for i in range(1, len(di[each])):
				(p, q) = (di[each][i - 1], di[each][i])
				if q - p < ans:
					ans = q - p
					anss = [p, q]
	print(anss[0] + 1, anss[1])


t = int(input())
arr = [2 * x for x in range(1, 10 ** 5 + 1)]
for z in range(0, t):
	n = int(input())
	s = list(input())
	dict = {}
	dict[0] = [1, 0]
	c = [0, 0]
	counter = 1
	min_len = 999999
	f_l = -1
	f_r = -1
	for i in s:
		if i == 'L':
			c[0] -= 1
		elif i == 'R':
			c[0] += 1
		elif i == 'U':
			c[1] += 1
		else:
			c[1] -= 1
		if c[0] * 546731844 + c[1] * 342865794235 in dict:
			dict[c[0] * 546731844 + c[1] * 342865794235].append(counter)
			dict[c[0] * 546731844 + c[1] * 342865794235][0] += 1
			dl = dict[c[0] * 546731844 + c[1] * 342865794235][0]
			duh = dict[c[0] * 546731844 + c[1] * 342865794235][dl] - dict[c[0] * 546731844 + c[1] * 342865794235][dl - 1]
			if duh < min_len:
				f_l = dict[c[0] * 546731844 + c[1] * 342865794235][dl - 1]
				f_r = dict[c[0] * 546731844 + c[1] * 342865794235][dl]
				min_len = duh
		else:
			dict[c[0] * 546731844 + c[1] * 342865794235] = [1, counter]
		counter += 1
	if f_l != -1:
		print(f_l + 1, end=' ')
		print(f_r)
	else:
		print(-1)


t = int(input())
for l in range(t):
	H = 0
	V = 0
	n = int(input())
	s = input()
	j = 0
	ans = 3 * 10 ** 5
	d = dict()
	ind1 = 0
	ind2 = 0
	d[0, 0] = 0
	for i in s:
		j += 1
		if i == 'L':
			H -= 1
		elif i == 'R':
			H += 1
		elif i == 'U':
			V += 1
		elif i == 'D':
			V -= 1
		if (H, V) in d.keys():
			if ans > j - d[H, V]:
				ans = j - d[H, V]
				ind1 = d[H, V]
				ind2 = j
			d[H, V] = j
		else:
			d[H, V] = j
	if ind1 == 0 and ind2 == 0:
		print(-1)
	else:
		print(ind1 + 1, ind2)


for Z in range(int(input())):
	n = int(input())
	di = {}
	di[0, 0] = 0
	m = n + 10
	a = -1
	b = -1
	s = input()
	s = 'X' + s
	curPos = (0, 0)
	ind = 1
	for i in s[1:]:
		li = list(curPos)
		if i == 'L':
			li[0] -= 1
		if i == 'R':
			li[0] += 1
		if i == 'U':
			li[1] += 1
		if i == 'D':
			li[1] -= 1
		curPos = tuple(li)
		if curPos in di:
			oldPosInd = di[curPos]
			if ind - oldPosInd < m:
				m = ind - oldPosInd
				a = oldPosInd + 1
				b = ind
		di[curPos] = ind
		ind += 1
	if m == n + 10:
		print('-1')
	else:
		print(a, b)


I = input
for _ in [0] * int(I()):
	I()
	a = {1: 1}
	i = s = 1
	r = (-1,)
	d = m = 7 << 15
	for c in I():
		s += (c == 'R') - (c == 'L') + d * ((c > 'R') - (c < 'L'))
		j = a.get(s, -m)
		if i - j < m:
			m = i - j
			r = (j, i)
		i += 1
		a[s] = i
	print(*r)


def min_rm(word):
	seen = {}
	table = {'L': (-1, 0), 'R': (1, 0), 'U': (0, 1), 'D': (0, -1)}
	mn = [0, float('inf')]
	current = (0, 0)
	for (i, d) in enumerate(word):
		seen[current] = i + 1
		(x, y) = current
		(ax, ay) = table[d]
		current = (x + ax, y + ay)
		if current in seen and i + 1 - seen[current] < mn[1] - mn[0]:
			mn = [seen[current], i + 1]
	return mn if mn[1] != float('inf') else [-1]
for _ in range(int(input())):
	_ = input()
	print(*min_rm(input()))


cases = int(input())
for casenum in range(cases):
	n = int(input())
	s = input()
	positions = {(0, 0): 0}
	bestresult = 300000
	bestplaceS = 0
	bestplaceE = 0
	curx = 0
	cury = 0
	move = 0
	for c in s:
		move += 1
		if c == 'U':
			curx += 1
		elif c == 'D':
			curx -= 1
		elif c == 'R':
			cury += 1
		elif c == 'L':
			cury -= 1
		if (curx, cury) in positions.keys():
			current = move - positions[curx, cury]
			if current < bestresult:
				bestresult = current
				bestplaceS = positions[curx, cury] + 1
				bestplaceE = move
		positions[curx, cury] = move
	if bestresult == 300000:
		print(-1)
	else:
		print(bestplaceS, bestplaceE)


from sys import stdin, stdout
from collections import defaultdict
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline()[:-1]
	d = defaultdict(list)
	d[0, 0].append(-1)
	(x, y) = (0, 0)
	f = [10000000.0, 10000000.0, 10000000.0]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		d[x, y].append(i)
		if len(d[x, y]) > 1:
			if d[x, y][-1] - d[x, y][-2] == 2:
				stdout.write(str(d[x, y][-2] + 2) + ' ' + str(d[x, y][-1] + 1) + '\n')
				break
			elif d[x, y][-1] - d[x, y][-2] < f[2]:
				f = [d[x, y][-1], d[x, y][-2], d[x, y][-1] - d[x, y][-2]]
	else:
		if 10000000.0 not in f:
			stdout.write(str(f[1] + 2) + ' ' + str(f[0] + 1) + '\n')
		else:
			stdout.write('-1\n')


t = int(input())
while t:
	t = t - 1
	n = int(input())
	string = [s for s in input()]
	dictonary = dict()
	x = 0
	y = 0
	dictonary[0, 0] = 0
	current_max_len = float('inf')
	l = 0
	r = 0
	for i in range(n):
		s = string[i]
		if s == 'R':
			x = x + 1
			if (x, y) in dictonary.keys():
				length = i + 1 - dictonary[x, y]
				if length < current_max_len:
					current_max_len = length
					l = dictonary[x, y] + 1
					r = i + 1
			dictonary[x, y] = i + 1
		if s == 'L':
			x = x - 1
			if (x, y) in dictonary.keys():
				length = i + 1 - dictonary[x, y]
				if length < current_max_len:
					current_max_len = length
					l = dictonary[x, y] + 1
					r = i + 1
			dictonary[x, y] = i + 1
		if s == 'U':
			y = y + 1
			if (x, y) in dictonary.keys():
				length = i + 1 - dictonary[x, y]
				if length < current_max_len:
					current_max_len = length
					l = dictonary[x, y] + 1
					r = i + 1
			dictonary[x, y] = i + 1
		if s == 'D':
			y = y - 1
			if (x, y) in dictonary.keys():
				length = i + 1 - dictonary[x, y]
				if length < current_max_len:
					current_max_len = length
					l = dictonary[x, y] + 1
					r = i + 1
			dictonary[x, y] = i + 1
	if l == 0 and r == 0:
		print('-1')
	else:
		print(l, end=' ')
		print(r)


def mindist(l):
	m = float('inf')
	ma = None
	for i in range(len(l) - 1):
		mc = l[i + 1] - l[i]
		if mc < m:
			m = mc
			ma = l[i]
	return (m, ma)
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	p = [0, 0]
	c = 0
	t = {tuple(p): [c]}
	for i in s:
		c += 1
		if i == 'L':
			p[0] -= 1
		elif i == 'R':
			p[0] += 1
		elif i == 'U':
			p[1] -= 1
		else:
			p[1] += 1
		if tuple(p) in t:
			t[tuple(p)].append(c)
		else:
			t[tuple(p)] = [c]
	m = float('inf')
	ma = None
	for p in t:
		(mpc, mapc) = mindist(t[p])
		if mpc < m:
			(m, ma) = (mpc, mapc)
	if ma == None:
		print(-1)
	else:
		print(ma + 1, ma + m)


t = int(input())
while t > 0:
	t -= 1
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	mp = {}
	ctr = 1
	mp['0,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 mp.get(str(x) + ',' + str(y)):
			mp[str(x) + ',' + str(y)].append(ctr)
		else:
			mp[str(x) + ',' + str(y)] = [ctr]
		ctr += 1
	mn = 2000000000
	(p, q) = (-1, -1)
	for (i, j) in mp.items():
		for k in range(0, len(j) - 1):
			x = j[k + 1] - (j[k] + 1)
			if mn > x:
				mn = x
				p = j[k] + 1
				q = j[k + 1]
	if mn == 2000000000:
		print(-1)
	else:
		print(p, q)


import sys
t = int(sys.stdin.readline().rstrip())
for _ in range(t):
	n = int(sys.stdin.readline().rstrip())
	s = sys.stdin.readline().rstrip()
	Sol = {}
	x = 0
	y = 0
	Sol[x, y] = 0
	best = n * 2
	aa = n * 2
	bb = n * 2
	for (nn, l) in enumerate(s):
		if l == 'U':
			y += 1
		elif l == 'D':
			y -= 1
		elif l == 'L':
			x -= 1
		elif l == 'R':
			x += 1
		if (x, y) in Sol:
			a = Sol[x, y]
			b = nn + 1
			if b - a + 1 < best:
				best = b - a + 1
				aa = a
				bb = b
		Sol[x, y] = nn + 1
	if aa == n * 2:
		print(-1)
	else:
		print(aa + 1, bb)


from sys import stdin
from math import ceil

def func():
	return
for _ in range(int(stdin.readline())):
	n = int(stdin.readline())
	s = stdin.readline().strip()
	(a, b) = (0, 0)
	d = {(0, 0): [0]}
	for i in range(n):
		if s[i] == 'L':
			a -= 1
		elif s[i] == 'R':
			a += 1
		elif s[i] == 'U':
			b += 1
		else:
			b -= 1
		if (a, b) in d:
			d[a, b].append(i + 1)
		else:
			d[a, b] = [i + 1]
	ans = {}
	for ele in d:
		if len(d[ele]) <= 1:
			pass
		else:
			for i in range(len(d[ele]) - 1):
				if d[ele][i + 1] - d[ele][i] in ans:
					ans[d[ele][i + 1] - d[ele][i]].append([d[ele][i] + 1, d[ele][i + 1]])
				else:
					ans[d[ele][i + 1] - d[ele][i]] = [[d[ele][i] + 1, d[ele][i + 1]]]
	if len(ans) == 0:
		print(-1)
	else:
		print(ans[min(ans)][0][0], ans[min(ans)][0][1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	d = dict()
	d[0, 0] = 0
	(x, y) = (0, 0)
	(l, r) = (-1, n)
	for (i, c) in enumerate(s):
		x += (1 if c == 'R' else 0) - (1 if c == 'L' else 0)
		y += (1 if c == 'U' else 0) - (1 if c == 'D' else 0)
		if (x, y) in d:
			if i - d[x, y] + 1 < r - l + 1:
				(l, r) = (d[x, y], i)
		d[x, y] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	(x, y) = (0, 0)
	d = dict()
	d[x, y] = [-1]
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'D':
			y -= 1
		else:
			y += 1
		if (x, y) in d:
			d[x, y].append(i)
		else:
			d[x, y] = [i]
	maxlen = -1
	(x1, y1) = (0, 0)
	for i in d:
		x = len(d[i])
		if x == 1:
			continue
		elif maxlen == -1:
			maxlen = d[i][1] - d[i][0]
			x1 = d[i][0]
			y1 = d[i][1]
		for j in range(1, x):
			if maxlen > d[i][j] - d[i][j - 1]:
				maxlen = d[i][j] - d[i][j - 1]
				(x1, y1) = (d[i][j - 1], d[i][j])
	if maxlen == -1:
		print(-1)
	else:
		print(x1 + 2, y1 + 1)


from sys import stdin, stdout
from math import pow
from os import path
if path.exists('inp.txt'):
	stdin = open('inp.txt', 'r')
q = int(stdin.readline())
for _ in range(q):
	n = int(stdin.readline())
	s = stdin.readline()
	M = {}
	M[0, 0] = 1
	(x, y, check, posx, posy, ans) = (0, 0, 0, 0, 0, int(1000000000.0))
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'D':
			y -= 1
		if s[i] == 'U':
			y += 1
		if (x, y) in M:
			if ans > i + 1 - M[x, y]:
				ans = i + 1 - M[x, y]
				posx = M[x, y]
				posy = i + 1
			check = 1
		M[x, y] = i + 2
	if not check:
		print('-1')
	else:
		print(posx, posy, sep=' ')


for _ in range(int(input())):
	n = int(input())
	a = input().strip()
	(l, r, x, y, f) = (0, n - 1, 0, 0, 1)
	b = {}
	b[0, 0] = 0
	for (j, i) in enumerate(a):
		x += (i == 'R') - (i == 'L')
		y += (i == 'U') - (i == 'D')
		if b.get((x, y)) != None:
			f = 0
			if r - l + 1 > j - b[x, y] + 1:
				r = j
				l = b[x, y]
		b[x, y] = j + 1
	if f:
		print(-1)
	else:
		print(l + 1, r + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	cp = [0, 0]
	p = []
	kp = {'0/0': 0}
	idx = []
	for i in range(n):
		if s[i] == 'L':
			cp[0] -= 1
		elif s[i] == 'R':
			cp[0] += 1
		elif s[i] == 'U':
			cp[1] += 1
		else:
			cp[1] -= 1
		p.append([cp[0], cp[1]])
		key = str(cp[0]) + '/' + str(cp[1])
		if key in kp:
			idx.append(i)
		else:
			kp[key] = i + 1
	res = [-1]
	diff = 100000000000000000000
	for i in range(len(idx)):
		key = str(p[idx[i]][0]) + '/' + str(p[idx[i]][1])
		if idx[i] - kp[key] < diff:
			diff = idx[i] - kp[key]
			res = [kp[key] + 1, idx[i] + 1]
		kp[key] = idx[i] + 1
	print(' '.join([str(x) for x in res]))


import math
from bisect import bisect_left, bisect_right
from sys import stdin, stdout
input = lambda : stdin.readline().strip()
print = lambda s: stdout.write(s)
t = int(input())
for i in range(t):
	n = int(input())
	s = input()
	cur = (0, 0)
	d1 = {(0, 0): [0]}
	cnt = []
	for i in range(n):
		if s[i] == 'U':
			cur = (cur[0], cur[1] + 1)
			try:
				d1[cur].append(i + 1)
				cnt.append((d1[cur][-2] + 1, d1[cur][-1]))
			except:
				d1[cur] = [i + 1]
		if s[i] == 'D':
			cur = (cur[0], cur[1] - 1)
			try:
				d1[cur].append(i + 1)
				cnt.append((d1[cur][-2] + 1, d1[cur][-1]))
			except:
				d1[cur] = [i + 1]
		if s[i] == 'R':
			cur = (cur[0] + 1, cur[1])
			try:
				d1[cur].append(i + 1)
				cnt.append((d1[cur][-2] + 1, d1[cur][-1]))
			except:
				d1[cur] = [i + 1]
		if s[i] == 'L':
			cur = (cur[0] - 1, cur[1])
			try:
				d1[cur].append(i + 1)
				cnt.append((d1[cur][-2] + 1, d1[cur][-1]))
			except:
				d1[cur] = [i + 1]
	cnt.sort(key=lambda x: x[1] - x[0])
	try:
		print(str(cnt[0][0]) + ' ' + str(cnt[0][1]) + '\n')
	except:
		print('-1\n')


from sys import stdin
from collections import defaultdict as dd
from math import inf
t = int(stdin.readline())
for _ in range(t):
	n = int(stdin.readline())
	pth = list(input())
	encntrd = dd(lambda : -1)
	cur = [0, 0]
	(l, r) = (0, inf)
	idx = 1
	encntrd[0, 0] = 0
	for ele in pth:
		if ele == 'L':
			cur[0] -= 1
		elif ele == 'R':
			cur[0] += 1
		elif ele == 'U':
			cur[1] += 1
		elif ele == 'D':
			cur[1] -= 1
		if encntrd[tuple(cur)] >= 0:
			ll = encntrd[tuple(cur)] + 1
			rr = idx
			if rr - ll < r - l:
				(l, r) = (ll, rr)
		encntrd[tuple(cur)] = idx
		idx += 1
	if l:
		print(l, r)
	else:
		print(-1)


from sys import stdin, stdout
import traceback
read = stdin.readline
write = stdout.write
writeln = lambda x: write(str(x) + '\n')

def reads(typ=int):
	return list(map(typ, read().split()))

class Sol:

	@classmethod
	def input(cls):
		s = cls()
		n = int(read())
		s.path = read().strip()
		return s

	def solve(self):
		ret = len(self.path) + 1
		ret_first = 0
		(x, y) = (0, 0)
		history = {}
		history[x, y] = -1
		for (i, c) in enumerate(self.path):
			if c == 'L':
				x -= 1
			elif c == 'R':
				x += 1
			elif c == 'U':
				y += 1
			elif c == 'D':
				y -= 1
			past = history.get((x, y), None)
			if past is not None:
				distance = i - past
				if distance < ret:
					ret = distance
					ret_first = past
			history[x, y] = i
		if ret == len(self.path) + 1:
			return -1
		else:
			return (ret_first + 2, ret_first + ret - 1 + 2)
try:
	for _ in range(int(read())):
		x = Sol.input().solve()
		if type(x) is tuple:
			writeln(' '.join([str(c) for c in x]))
		else:
			writeln(x)
except Exception as e:
	print('Got exception:', repr(e))
	print(traceback.format_exc())


for _ in range(int(input())):
	n = int(input())
	s = input()
	cur = (0, 0)
	dic = {(0, 0): 0}
	(l, r) = (-1, n)
	for (i, a) in enumerate(s):
		(f, s) = cur
		if a == 'L':
			cur = (f - 1, s)
		if a == 'R':
			cur = (f + 1, s)
		if a == 'U':
			cur = (f, s + 1)
		if a == 'D':
			cur = (f, s - 1)
		if cur in dic:
			if i - dic[cur] + 1 < r - l + 1:
				(l, r) = (dic[cur], i)
		dic[cur] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


for _ in range(int(input())):
	n = int(input())
	s = input()
	(x, y) = (0, 0)

	def change(x, y, c):
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		else:
			y -= 1
		return (x, y)
	(x, y) = (0, 0)
	vis = {(0, 0): 0}
	ans = -1
	mini = 10 ** 6
	for i in range(n):
		(x, y) = change(x, y, s[i])
		if (x, y) in vis:
			if i - vis[x, y] < mini:
				ans = [vis[x, y] + 1, i + 1]
				mini = i - vis[x, y]
		vis[x, y] = i + 1
	if ans != -1:
		print(*ans)
	else:
		print(ans)


from collections import *
for _ in range(int(input())):
	n = int(input())
	s = input()
	d = {}
	d[0] = {}
	d[0][0] = 0
	l = -1
	r = -1
	x = 0
	y = 0
	mn = 1e+18
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		try:
			h = i - d[x][y]
			if h < mn:
				r = i
				l = d[x][y]
				mn = min(h, mn)
			d[x][y] = i + 1
		except:
			try:
				if len(d[x]):
					d[x][y] = i + 1
			except:
				d[x] = {}
				d[x][y] = i + 1
	if mn == 1e+18:
		print(-1)
	else:
		print(l + 1, r + 1)


N = int(input())
for _ in range(N):
	d = {(0, 0): 0}
	n = int(input())
	s = input()
	start = end = -1
	length = n + 1
	x = y = 0
	for (i, c) in enumerate(s):
		idx = i + 1
		if c == 'L':
			x -= 1
		elif c == 'R':
			x += 1
		elif c == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in d:
			prev_idx = d[x, y] + 1
			if idx - prev_idx < length:
				length = idx - prev_idx
				(start, end) = (prev_idx, idx)
		d[x, y] = idx
	if start == -1:
		print(-1)
	else:
		print(start, end)


from __future__ import division, print_function
from fractions import Fraction
import sys
import os
from io import BytesIO, IOBase
import bisect
from heapq import *
from math import *
from collections import deque
from collections import Counter as counter
from itertools import combinations as comb
from itertools import permutations as permutate
from bisect import bisect_left as bl
from bisect import bisect_right as br
from bisect import bisect
BUFSIZE = 8192

class FastIO(IOBase):
	newlines = 0

	def __init__(self, file):
		self._fd = file.fileno()
		self.buffer = BytesIO()
		self.writable = 'x' in file.mode or 'r' not in file.mode
		self.write = self.buffer.write if self.writable else None

	def read(self):
		while True:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			if not b:
				break
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines = 0
		return self.buffer.read()

	def readline(self):
		while self.newlines == 0:
			b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
			self.newlines = b.count(b'\n') + (not b)
			ptr = self.buffer.tell()
			(self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr))
		self.newlines -= 1
		return self.buffer.readline()

	def flush(self):
		if self.writable:
			os.write(self._fd, self.buffer.getvalue())
			(self.buffer.truncate(0), self.buffer.seek(0))

class IOWrapper(IOBase):

	def __init__(self, file):
		self.buffer = FastIO(file)
		self.flush = self.buffer.flush
		self.writable = self.buffer.writable
		self.write = lambda s: self.buffer.write(s.encode('ascii'))
		self.read = lambda : self.buffer.read().decode('ascii')
		self.readline = lambda : self.buffer.readline().decode('ascii')

def print(*args, **kwargs):
	(sep, file) = (kwargs.pop('sep', ' '), kwargs.pop('file', sys.stdout))
	at_start = True
	for x in args:
		if not at_start:
			file.write(sep)
		file.write(str(x))
		at_start = False
	file.write(kwargs.pop('end', '\n'))
	if kwargs.pop('flush', False):
		file.flush()
if sys.version_info[0] < 3:
	(sys.stdin, sys.stdout) = (FastIO(sys.stdin), FastIO(sys.stdout))
else:
	(sys.stdin, sys.stdout) = (IOWrapper(sys.stdin), IOWrapper(sys.stdout))
mod = 1000000007

def inp():
	return sys.stdin.readline().rstrip('\r\n')

def out(var):
	sys.stdout.write(str(var))

def lis():
	return list(map(int, inp().split()))

def stringlis():
	return list(map(str, inp().split()))

def sep():
	return map(int, inp().split())

def strsep():
	return map(str, inp().split())

def graph(vertex):
	return [[] for i in range(0, vertex + 1)]

def zerolist(n):
	return [0] * n

def nextline():
	out('\n')

def testcase(t):
	for p in range(t):
		solve()

def printlist(a):
	for p in range(0, len(a)):
		out(str(a[p]) + ' ')

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

def power(a, b):
	ans = 1
	while b > 0:
		if b % 2 == 1:
			ans *= a
		a *= a
		b //= 2
	return ans

def ncr(n, r):
	return factorial(n) // (factorial(r) * factorial(max(n - r, 1)))

def isPrime(n):
	if n <= 1:
		return False
	if n <= 3:
		return True
	if n % 2 == 0 or n % 3 == 0:
		return False
	i = 5
	while i * i <= n:
		if n % i == 0 or n % (i + 2) == 0:
			return False
		i = i + 6
	return True

def bs(a, l, h, x):
	while l < h:
		mid = (l + h) // 2
		if a[mid] == x:
			return mid
		if a[mid] < x:
			l = mid + 1
		else:
			h = mid
	return l

def sieve(a):
	for i in range(3, 10 ** 6 + 1, 2):
		a[i] = 1
	for i in range(3, 10 ** 6 + 1, 2):
		for j in range(i * i, 10 ** 6 + 1, i):
			a[j] = 0
	a[2] = 1
	return a

def bfs(g, st):
	visited = [0] * len(g)
	visited[st] = 1
	queue = []
	queue.append(st)
	new = []
	while len(queue) != 0:
		s = queue.pop()
		new.append(s)
		for i in g[s]:
			if visited[i] == 0:
				visited[i] = 1
				queue.append(i)
	return new

def solve():
	n = int(inp())
	s = inp()
	d = {}
	cnt = 1
	d['0,0'] = 0
	x = 0
	y = 0
	ans = [1, 10 ** 9]
	for i in range(0, n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if d.get(str(x) + ',' + str(y)) != None and ans[1] - ans[0] + 1 > cnt - d[str(x) + ',' + str(y)]:
			ans[0] = d[str(x) + ',' + str(y)] + 1
			ans[1] = cnt
		d[str(x) + ',' + str(y)] = cnt
		cnt += 1
	if ans[1] == 10 ** 9:
		print(-1)
	else:
		print(*ans)
testcase(int(inp()))


t = int(input())
for g in range(t):
	n = int(input())
	s = input()
	q = dict()
	pos = [0, 0]
	(l, r) = (-1, n)
	for i in range(n):
		q[tuple(pos)] = i
		if s[i] == 'L':
			pos[0] -= 1
		elif s[i] == 'R':
			pos[0] += 1
		elif s[i] == 'U':
			pos[1] += 1
		else:
			pos[1] -= 1
		if tuple(pos) in q:
			if i - q[tuple(pos)] + 1 < r - l + 1:
				(l, r) = (q[tuple(pos)], i)
		q[tuple(pos)] = i + 1
	if l == -1:
		print(-1)
	else:
		print(l + 1, r + 1)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	x = 0
	y = 0
	raj = dict()
	minn = n + 10
	a = 1
	b = n
	raj[0, 0] = -1
	for i in range(len(s)):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if raj.get((x, y)) == None:
			raj[x, y] = i
		else:
			l = raj.get((x, y))
			r = i
			if r - l < minn:
				a = l + 1
				b = r
				minn = r - l
			raj[x, y] = i
	if minn == n + 10:
		print(-1)
	else:
		print(a + 1, b + 1)


from sys import stdin, stdout
import math
import collections
input = stdin.readline

def print(x='', y='', end='\n'):
	if y != '':
		stdout.write(str(x) + ' ' + str(y) + end)
	else:
		stdout.write(str(x) + end)

def solve():
	n = int(input())
	l = input()
	cur = [0, 0]
	d = {tuple(cur): 0}
	(st, end) = (-1, n)
	for i in range(n):
		if l[i] == 'L':
			cur[0] += 1
		elif l[i] == 'R':
			cur[0] -= 1
		elif l[i] == 'U':
			cur[1] += 1
		else:
			cur[1] -= 1
		t = tuple(cur)
		if t in d:
			if i - d[t] < end - st:
				end = i
				st = d[t]
		d[t] = i + 1
	if st == -1:
		print(-1)
		return
	print(st + 1, end + 1)
tt = 1
tt = int(input())
for __ in range(tt):
	solve()


T = int(input())
for t in range(T):
	n = int(input())
	s = ' ' + input()
	(sum1, sum2, ans, l, r) = (0, 0, n + 1, -1, -1)
	d = {}
	d[0, 0] = 1
	for i in range(1, n + 1):
		if s[i] == 'U':
			sum1 += 1
		elif s[i] == 'D':
			sum1 -= 1
		elif s[i] == 'R':
			sum2 += 1
		else:
			sum2 -= 1
		if d.get((sum1, sum2)) is not None:
			cur_res = i - d[sum1, sum2]
			if cur_res < ans:
				ans = cur_res
				r = i
				l = d[sum1, sum2]
		d[sum1, sum2] = i + 1
	if ans == n + 1:
		print('-1')
	else:
		print(l, r)


import sys
from collections import defaultdict

def stdinWrapper():
	data = '2\n221\nRUURRUURRLLDLRRLUDLLLRRULRUUDLDULRRRDRDLDRDLRUUDLUDLDRDDLRRLURDLRUURRUDDLURRUDLDLRULRLLUDDULRDLLRLUDURDLUDLULUULLUDURLULDLLRRLRURDLRRRDLLULURULUUUUUDDRRRRDURURRRDLRUDLRRLLLRLDRURUDLRUUDLULDLRUDDDDRLDDDULLRURDLLRULUURUDLLL\n209\nRURDLUDLLULURDLDRDRDLLULUURULUULDUDUULLRDDURDRRRULULLRULURUDDLLUDRRRRLURUURRRRLDULRLDRLULULUURDDUUURLRUUUUULRRLLRDDUULRRUUUDDDRRURUULLRUUULDDDRLDRULLDLURLLRRURLRRURDLLDLRDDDRLRLUURLLLULRUULDDUDDULDLDLRLUDDURDL\n'
	for line in data.split('\n'):
		yield line
if '--debug' not in sys.argv:

	def stdinWrapper():
		while True:
			yield input()
inputs = stdinWrapper()

def inputWrapper():
	return next(inputs)

def getType(_type):
	return _type(inputWrapper())

def getArray(_type):
	return [_type(x) for x in inputWrapper().split()]

def encode(pos):
	return '{}:{}'.format(*pos)

def decode(pos):
	return [int(x) for x in pos.split(':')]
t = getType(int)
for _ in range(t):
	l = getType(int)
	path = getType(str)
	graph = {}
	pos = [0, 0]
	graph[encode(pos)] = 0
	res_start = -1
	res_end = l
	for (i, cmd) in enumerate(path):
		if cmd == 'L':
			pos[0] -= 1
		elif cmd == 'R':
			pos[0] += 1
		elif cmd == 'U':
			pos[1] += 1
		elif cmd == 'D':
			pos[1] -= 1
		if encode(pos) in graph:
			temp_res_start = graph[encode(pos)] + 1
			temp_res_end = i + 1
			if temp_res_end - temp_res_start < res_end - res_start:
				res_start = temp_res_start
				res_end = temp_res_end
		graph[encode(pos)] = i + 1
	if res_start == -1:
		print(-1)
	else:
		print(res_start, res_end)


for _ in range(int(input())):
	n = int(input())
	s = input()
	dic = {str(list([0, 0])): [-1]}
	x = 0
	y = 0
	for i in range(n):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if dic.get(str([x, y]), -1) == -1:
			dic[str([x, y])] = [i]
		else:
			dic[str([x, y])].append(i)
	count = 10 ** 8
	cor = []
	for j in dic:
		if len(dic[j]) > 1:
			for z in range(1, len(dic[j])):
				if dic[j][z] - dic[j][z - 1] < count:
					count = dic[j][z] - dic[j][z - 1]
					cor = list([dic[j][z - 1] + 2, dic[j][z] + 1])
	if count == 10 ** 8:
		print(-1)
	else:
		print(*cor)


import sys

def input():
	a = sys.stdin.readline()
	if a[-1] == '\n':
		a = a[:-1]
	return a

def print(*argv):
	n = len(argv)
	for i in range(n):
		if i == n - 1:
			sys.stdout.write(str(argv[i]) + '\n')
		else:
			sys.stdout.write(str(argv[i]) + ' ')

def lcm(x, y):
	from math import gcd
	return x * y / gcd(x, y)

def comb(lst, x):
	from itertools import combination as c
	return list(comb(lst, x))

def solve(n, lst):
	check = [0] * 4
	for i in range(n - 1):
		if lst[i] == 'L' and lst[i + 1] == 'R':
			return (i + 1, i + 2)
		elif lst[i] == 'R' and lst[i + 1] == 'L':
			return (i + 1, i + 2)
		elif lst[i] == 'U' and lst[i + 1] == 'D':
			return (i + 1, i + 2)
		elif lst[i] == 'D' and lst[i + 1] == 'U':
			return (i + 1, i + 2)
	check = {(0, 0): [float('inf'), -1, -1]}
	(v, h) = (0, 0)
	for i in range(n):
		if lst[i] == 'U':
			v += 1
		elif lst[i] == 'D':
			v -= 1
		elif lst[i] == 'R':
			h += 1
		else:
			h -= 1
		if check.get((v, h)) == None:
			check[v, h] = [float('inf'), i, -1]
		else:
			val = check[v, h]
			if val[0] > i - val[1] + 1:
				check[v, h] = [i - val[1], i, i]
			else:
				check[v, h] = [val[0], i, val[2]]
	(minn, ans) = (float('inf'), (-1, -1))
	for i in check.values():
		if i[0] < minn:
			minn = i[0]
			ans = (i[2] - minn + 2, i[2] + 1)
	if minn == float('inf'):
		return (-1, -1)
	else:
		return ans
for _ in range(int(input())):
	n = int(input())
	lst = input()
	val = solve(n, lst)
	if val[0] == -1:
		print(-1)
	else:
		print(val[0], val[1])


def f(n):
	return 10 * (n // 10)
t = int(input())
for you in range(t):
	n = int(input())
	l = input()
	x = 0
	y = 0
	lo = []
	for i in l:
		if i == 'L':
			x -= 1
		elif i == 'R':
			x += 1
		elif i == 'D':
			y -= 1
		else:
			y += 1
		lo.append((x, y))
	hashi = dict()
	lfi = []
	hashi[0, 0] = 0
	for i in range(n):
		if lo[i] in hashi:
			lfi.append((i - hashi[lo[i]], hashi[lo[i]] + 1, i + 1))
			hashi[lo[i]] = i + 1
		else:
			hashi[lo[i]] = i + 1
	if lfi == []:
		print(-1)
	else:
		k = min(lfi)
		print(k[1], k[2])


from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 5)
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
from sys import stdin
from collections import deque
mod = 10 ** 9 + 7
import sys
sys.setrecursionlimit(10 ** 5)
from queue import PriorityQueue
from bisect import bisect_right
from bisect import bisect_left
from collections import defaultdict
from math import sqrt, factorial, gcd, log2, inf, ceil
import heapq
input = lambda : sys.stdin.readline().rstrip()
from sys import stdin, stdout
from heapq import heapify, heappush, heappop
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	seti = set()
	(x, y) = (0, 0)
	hash = defaultdict(int)
	seti.add((x, y))
	hash[x, y] = -1
	mini = inf
	ans1 = -1
	ans2 = -1
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		if (x, y) in seti:
			z = hash[x, y]
			if z == -1:
				z = 0
				len = i - z + 1
				z = -1
			else:
				len = i - z
			mini = min(mini, len)
			if mini == len:
				if z == -1:
					z = 0
					ans1 = z + 1
					ans2 = i + 1
				else:
					ans1 = z + 2
					ans2 = i + 1
			hash[x, y] = i
		hash[x, y] = i
		seti.add((x, y))
	if ans1 == -1 or ans2 == -1:
		print(-1)
	else:
		print(ans1, ans2)


t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	path = {}
	path[0, 0] = 0
	(x, y) = (0, 0)
	r = n + 1
	sstring = 0
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		if (x, y) in path:
			l = i - path[x, y]
			if l < r:
				r = l
				sstring = (path[x, y] + 1, i + 1)
		path[x, y] = i + 1
	if sstring:
		print(*sstring)
	else:
		print(-1)


def findSubArrays(arr, n):
	hashMap = {}
	sum1 = 0
	diff = 100000000
	st = 0
	end = 0
	for i in range(n):
		sum1 += arr[i]
		if sum1 == 0:
			if i - 0 < diff:
				st = 0
				end = i
				diff = i - 0
		al = []
		if diff == 1:
			break
		if sum1 in hashMap:
			al = hashMap.get(sum1)
			for it in range(len(al)):
				if i - (al[it] + 1) < diff:
					diff = i - (al[it] + 1)
					st = al[it] + 1
					end = i
		al.append(i)
		hashMap[sum1] = al
	if diff == 100000000:
		print(-1)
		return
	else:
		print(st + 1, end + 1)
		return
t = int(input())
while t > 0:
	n = int(input())
	s = input()
	l = []
	for i in s:
		if i == 'L':
			l.append(1)
		elif i == 'R':
			l.append(-1)
		elif i == 'U':
			l.append(200000)
		else:
			l.append(-200000)
	findSubArrays(l, n)
	t -= 1


import math
from decimal import *
import random
mod = int(1000000000.0) + 7
for _ in range(int(input())):
	(start, end) = (0, 3 * (10 ** 5 + 1))
	n = int(input())
	s = str(input())
	(x, y) = (0, 0)
	d = {}
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		if s[i] == 'R':
			x += 1
		if s[i] == 'U':
			y += 1
		if s[i] == 'D':
			y -= 1
		t = tuple([x, y])
		if t == (0, 0) and (0, 0) not in d:
			if i + 1 < end - start + 1:
				start = 1
				end = int(i + 1)
			d[0, 0] = int(i + 1)
		elif t not in d:
			d[t] = int(i + 1)
		elif t in d:
			if i + 1 - d[t] + 1 < end - start + 1:
				start = d[t] + 1
				end = int(i + 1)
			d[t] = int(i + 1)
	if end == 3 * (10 ** 5 + 1):
		print(-1)
	else:
		print(start, end)


t = int(input())
for _ in range(t):
	n = int(input())
	string = input()
	opt = {(0, 0): [0]}
	ox = oy = 0
	for (i, c) in enumerate(string):
		if c == 'L':
			oy -= 1
		if c == 'R':
			oy += 1
		if c == 'U':
			ox += 1
		if c == 'D':
			ox -= 1
		if (ox, oy) not in opt:
			opt[ox, oy] = [i + 1]
		else:
			opt[ox, oy].append(i + 1)
	(l, r) = (0, n + 1)
	for key in opt.keys():
		a = opt[key]
		if len(a) > 1:
			for i in range(1, len(a)):
				if a[i] - a[i - 1] < r - l:
					r = a[i]
					l = a[i - 1]
	if r == n + 1:
		print(-1)
	else:
		print(l + 1, r)


import sys, re, math
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from heapq import heappush, heappop, heapify, nlargest, nsmallest

def STR():
	return list(input())

def INT():
	return int(input())

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

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

def list2d(a, b, c):
	return [[c] * b for i in range(a)]

def sortListWithIndex(listOfTuples, idx):
	return sorted(listOfTuples, key=lambda x: x[idx])

def sortDictWithVal(passedDic):
	temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
	toret = {}
	for tup in temp:
		toret[tup[0]] = tup[1]
	return toret

def sortDictWithKey(passedDic):
	return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

def change(X, Y, ch):
	if ch == 'L':
		return (X - 1, Y)
	elif ch == 'R':
		return (X + 1, Y)
	elif ch == 'U':
		return (X, Y + 1)
	return (X, Y - 1)
t = INT()
while t != 0:
	n = INT()
	s = input()
	coord = {}
	x = y = 0
	ansCoord = (0, 0)
	coord[ansCoord] = 1
	minAns = INF
	for (i, ch) in enumerate(s):
		(x, y) = change(x, y, ch)
		if (x, y) in coord:
			temp = i + 1 - coord[x, y]
			if temp < minAns:
				minAns = temp
				ansCoord = (coord[x, y], i + 1)
		coord[x, y] = i + 2
	if minAns == INF:
		print(-1)
	else:
		print(*ansCoord)
	t -= 1


t = int(input())
for ii in range(t):
	n = int(input())
	a = list(input())
	p = [[0, 0, 0]]
	x = 0
	y = 0
	for i in range(n):
		if a[i] == 'L':
			x -= 1
		elif a[i] == 'R':
			x += 1
		elif a[i] == 'U':
			y += 1
		else:
			y -= 1
		p.append([x, y, i + 1])
	p.sort()
	m = n + 1
	for i in range(n):
		if p[i][0] == p[i + 1][0] and p[i][1] == p[i + 1][1]:
			if p[i + 1][2] - p[i][2] < m:
				ans = [p[i][2] + 1, p[i + 1][2]]
				m = p[i + 1][2] - p[i][2]
	if m == n + 1:
		print(-1)
	else:
		print(*ans)


def main():
	t = int(input())
	for _ in range(t):
		n = int(input())
		s = input()
		ma = {(0, 0): -1}
		(hz, ve) = (0, 0)
		ret = n + 2
		(l, r) = (None, None)
		for i in range(n):
			if s[i] == 'D':
				ve += 1
			elif s[i] == 'U':
				ve -= 1
			elif s[i] == 'R':
				hz += 1
			else:
				hz -= 1
			if (hz, ve) in ma:
				if i - ma[hz, ve] < ret:
					ret = i - ma[hz, ve]
					(l, r) = (ma[hz, ve] + 1, i)
			ma[hz, ve] = i
		if ret > n:
			print(-1)
		else:
			print(l + 1, r + 1)
main()


t = int(input())
for i in range(t):
	n = int(input())
	ch = input()
	d = {(0, 0): 0}
	p = (0, 0)
	dis = n + 1
	x = 0
	y = 0
	for i in range(n):
		if ch[i] == 'L':
			p = (p[0] - 1, p[1])
		elif ch[i] == 'R':
			p = (p[0] + 1, p[1])
		elif ch[i] == 'U':
			p = (p[0], p[1] + 1)
		else:
			p = (p[0], p[1] - 1)
		if p not in d:
			f = 1
		elif abs(i - d[p]) < dis:
			y = i
			x = d[p]
			dis = abs(i - d[p])
		d[p] = i + 1
	if dis == n + 1:
		print(-1)
	else:
		print(x + 1, y + 1)


def ri():
	return int(input())

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

def solve():
	n = ri()
	S = input().strip()
	pos = [0, 0]
	last_seen = {(0, 0): -1}
	best = 10 ** 10
	best_ind = (-1, -1)
	for (i, d) in enumerate(S):
		if d == 'L':
			pos[0] -= 1
		elif d == 'R':
			pos[0] += 1
		elif d == 'U':
			pos[1] -= 1
		else:
			pos[1] += 1
		if tuple(pos) in last_seen and i - last_seen[tuple(pos)] < best:
			best = i - last_seen[tuple(pos)]
			best_ind = (last_seen[tuple(pos)] + 2, i + 1)
		last_seen[tuple(pos)] = i
	if best == 10 ** 10:
		print(-1)
	else:
		print(*best_ind)
	return
t = ri()
for i in range(t):
	solve()


import sys
for _ in range(int(input())):
	n = int(sys.stdin.readline().split()[0])
	s = sys.stdin.readline().split()[0]
	x = [(0, 0, 0)] + [None] * n
	for i in range(1, n + 1):
		x[i] = (x[i - 1][0] + {'L': -1, 'R': 1, 'U': 0, 'D': 0}[s[i - 1]], x[i - 1][1] + {'L': 0, 'R': 0, 'U': 1, 'D': -1}[s[i - 1]], i)
	x.sort()
	minn = n + 1
	tup = None
	for j in range(n):
		if x[j][0] == x[j + 1][0] and x[j][1] == x[j + 1][1]:
			if abs(x[j][2] - x[j + 1][2]) < minn:
				minn = abs(x[j][2] - x[j + 1][2])
				tup = sorted([x[j][2], x[j + 1][2]])
				tup[0] += 1
	if minn == n + 1:
		print(-1)
		continue
	print(*tup)


import sys
T = int(sys.stdin.readline())
dx = [1, -1, 0, 0]
dy = [0, 0, 1, -1]
for _ in range(T):
	n = int(sys.stdin.readline())
	s = sys.stdin.readline().strip()
	xy = {'L': 1, 'R': 0, 'U': 2, 'D': 3}
	dict_visit = {(0, 0): 0}
	now = [0, 0]
	res = (0, 200005)
	for (c, d) in enumerate(s):
		c += 1
		now[0] += dx[xy[d]]
		now[1] += dy[xy[d]]
		nxy = (now[0], now[1])
		if nxy in dict_visit:
			res = min(res, (dict_visit[nxy] + 1, c), key=lambda x: x[1] - x[0])
		dict_visit[nxy] = c
	if res == (0, 200005):
		print(-1)
	else:
		print(*res)


from collections import defaultdict
for _ in range(int(input())):
	n = int(input())
	s = input()
	lastP = {(0, 0): -1}
	x = 0
	y = 0
	ans = -1
	for i in range(n):
		if s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if (x, y) in lastP:
			lp = lastP[x, y]
			interval = i - lp
			if ans == -1 or interval < ans[1] - ans[0]:
				ans = (lp + 2, i + 1)
		lastP[x, y] = i
	if ans != -1:
		print(*ans)
	else:
		print(-1)


from sys import stdin
input = stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	t = set()
	y = 0
	x = 0
	dc = {0: 0}
	m = 10 ** 18
	ans = (-1, -1)
	for i in range(n):
		if s[i] == 'L':
			x -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'U':
			y += 1
		else:
			y -= 1
		if y * 10 ** 9 + x in dc:
			if m > i + 1 - dc[y * 10 ** 9 + x]:
				m = i + 1 - dc[y * 10 ** 9 + x]
				ans = (dc[y * 10 ** 9 + x] + 1, i + 1)
		dc[y * 10 ** 9 + x] = i + 1
	if m == 10 ** 18:
		print(-1)
	else:
		print(*ans)


t = int(input())
for x in range(t):
	n = int(input())
	a = input()
	(x, y) = (0, 0)
	s = dict()
	s[0, 0] = 0
	anss = []
	t = 1
	for i in a:
		if i == 'U':
			y += 1
		elif i == 'D':
			y -= 1
		elif i == 'R':
			x += 1
		elif i == 'L':
			x -= 1
		if (x, y) in s:
			anss.append((s[x, y], t - 1))
			s[x, y] = t
		else:
			s[x, y] = t
		t += 1
	if len(anss) == 0:
		print(-1)
	else:
		h = min(anss, key=lambda x: x[1] - x[0])
		print(h[0] + 1, h[1] + 1)


import sys
input = sys.stdin.readline
t = int(input())
for _ in range(t):
	n = int(input())
	it = list(input())
	ss = {}
	x = 0
	y = 0
	ss[0, 0] = -1
	mi = n + 1
	ans = []
	for i in range(n):
		if it[i] == 'L':
			x -= 1
		elif it[i] == 'R':
			x += 1
		elif it[i] == 'U':
			y += 1
		else:
			y -= 1
		try:
			xx = ss[x, y]
			if i + 1 - xx - 2 + 1 < mi:
				mi = i + 1 - xx - 2 + 1
				ans = [xx + 2, i + 1]
		except:
			pass
		ss[x, y] = i
	if ans == []:
		print(-1)
		continue
	print(*ans)


T = int(input())
for case in range(T):
	n = int(input())
	s = input()
	x = y = 0
	dir = [[-1, 0], [1, 0], [0, 1], [0, -1]]
	dirs = 'LRUD'
	vis = {}
	vis[0, 0] = 0
	minLen = n + 1
	l = r = -1
	for i in range(n):
		idx = dirs.index(s[i])
		x += dir[idx][0]
		y += dir[idx][1]
		if (x, y) in vis:
			nl = vis[x, y] + 1
			nr = i + 1
			if nr - nl + 1 < minLen:
				minLen = nr - nl + 1
				(l, r) = (nl, nr)
		vis[x, y] = i + 1
	if l != -1:
		print(l, r)
	else:
		print('-1')


import sys
import math
import heapq
import bisect
import re
from collections import deque
from decimal import *
from fractions import gcd

def YES_NO(flag):
	if flag:
		print('YES')
	else:
		print('NO')

def main():
	n = int(sys.stdin.readline())
	s = sys.stdin.readline()
	q = [(0, 0) for i in range(n + 5)]
	w = dict()
	(res, resl, resr) = (1000000000.0, 0, 0)
	for i in range(n):
		if s[i] == 'U':
			q[i + 1] = (q[i][0], q[i][1] + 1)
		elif s[i] == 'R':
			q[i + 1] = (q[i][0] + 1, q[i][1])
		elif s[i] == 'L':
			q[i + 1] = (q[i][0] - 1, q[i][1])
		else:
			q[i + 1] = (q[i][0], q[i][1] - 1)
	for i in range(n + 1):
		if q[i] in w:
			w[q[i]].append(i)
		else:
			w[q[i]] = [i]
	for i in range(n):
		t = bisect.bisect(w[q[i]], i)
		if t != len(w[q[i]]):
			if res > w[q[i]][t] - i - 1:
				(res, resl, resr) = (w[q[i]][t] - i - 1, i + 1, w[q[i]][t])
	if res != 1000000000.0:
		print(resl, resr)
		return 0
	print(-1)
for i in range(int(sys.stdin.readline())):
	main()


from collections import defaultdict as dd
t = int(input())
while t:
	x = 0
	y = 0
	d = dd(list)
	d[x, y].append(0)
	n = int(input())
	s = input()
	for i in range(1, n + 1):
		if s[i - 1] == 'L':
			x -= 1
			d[x, y].append(i)
		elif s[i - 1] == 'R':
			x += 1
			d[x, y].append(i)
		elif s[i - 1] == 'U':
			y += 1
			d[x, y].append(i)
		else:
			y -= 1
			d[x, y].append(i)
	mx = 1000000000000000
	mi = -1
	for i in d:
		if len(i) > 1:
			for j in range(1, len(d[i])):
				if mx > d[i][j] - d[i][j - 1]:
					mi = d[i][j - 1]
					mj = d[i][j]
					mx = d[i][j] - d[i][j - 1]
	if mi != -1:
		print(mi + 1, mj)
	else:
		print(-1)
	t -= 1


t = int(input())
for h in range(t):
	n = int(input())
	s = input()
	mp = {10000001000000: -1}
	pr = 0
	x = 1000000
	y = 1000000
	le = 10000000
	in1 = 0
	in2 = 0
	for i in range(n):
		if s[i] == 'U':
			y += 1
		elif s[i] == 'D':
			y -= 1
		elif s[i] == 'R':
			x += 1
		elif s[i] == 'L':
			x -= 1
		kx = x * 10000000 + y
		if mp.get(kx) != None:
			if i - mp[kx] < le:
				le = i - mp[kx]
				in1 = mp[kx] + 2
				in2 = i + 1
			mp[kx] = i
		else:
			mp[kx] = i
	if le == 10000000:
		if x == 1000000 and y == 1000000:
			print(1, n)
		else:
			print(-1)
	else:
		print(in1, in2)


t = int(input())
while t:
	t -= 1
	n = int(input())
	path = input()
	pos = {(0, 0): 0}
	(x, y) = (0, 0)
	ans = (-1, -1)
	for i in range(n):
		ch = path[i]
		if ch == 'U':
			y += 1
		elif ch == 'D':
			y -= 1
		elif ch == 'L':
			x -= 1
		else:
			x += 1
		ret = pos.get((x, y))
		if ret is None:
			pos[x, y] = i + 1
		else:
			if ans[1] - ans[0] > i - ret or ans[1] == -1:
				ans = (ret + 1, i + 1)
			pos[x, y] = i + 1
	if ans[0] == -1:
		print(-1)
	else:
		print(ans[0], ans[1])


for _ in range(int(input())):
	n = int(input())
	s = input()
	balance = 0
	index = {0: 1}
	ans = [10 ** 9]
	i = 1
	for x in s:
		if x == 'U':
			balance += 10 ** 9
		elif x == 'D':
			balance -= 10 ** 9
		elif x == 'L':
			balance += 1
		else:
			balance -= 1
		if balance in index:
			ans = min(ans, [i + 1 - index[balance], index[balance], i])
		index[balance] = i + 1
		i += 1
	if ans[0] == 10 ** 9:
		print(-1)
	else:
		print(ans[1], ans[2])


def char_resolution(char):
	if char == 'L':
		return (-1, 0)
	elif char == 'R':
		return (1, 0)
	elif char == 'U':
		return (0, 1)
	else:
		return (0, -1)
cases_count = int(input())
for i in range(0, cases_count):
	case_count = int(input())
	case = str(input())
	x = 0
	y = 0
	answer_store = {(0, 0): 0}
	p_start = -1
	p_end = -1
	for char_index in range(0, case_count):
		(delta_x, delta_y) = char_resolution(case[char_index])
		x += delta_x
		y += delta_y
		if (x, y) in answer_store and (p_start == -1 or char_index - answer_store[x, y] < p_end - p_start):
			p_start = answer_store[x, y] + 1
			p_end = char_index + 1
		answer_store[x, y] = char_index + 1
	print('-1' if p_start == -1 else f'{p_start} {p_end}')


def ip():
	for _ in range(int(input())):
		n = int(input())
		s = input()
		(x, y) = (0, 0)
		m = {(0, 0): [0]}
		d = float('inf')
		(st, end) = (0, 0)
		for i in range(n):
			if s[i] == 'L':
				x -= 1
			elif s[i] == 'R':
				x += 1
			elif s[i] == 'U':
				y += 1
			else:
				y -= 1
			t = (x, y)
			if m.get(t) == None:
				m[t] = [i + 1]
			else:
				prev = m[t][-1]
				m[t].append(i + 1)
				if d > i + 1 - prev:
					d = i + 1 - prev
					st = prev + 1
					end = i + 1
		if d == float('inf'):
			print(-1)
		else:
			print(st, end)
ip()


for t in range(int(input())):
	n = int(input())
	s = input()
	h = 0
	v = 0
	a = {}
	a['0,0'] = 0
	left = -1
	right = n
	for i in range(n):
		if s[i] == 'L':
			h -= 1
		elif s[i] == 'R':
			h += 1
		elif s[i] == 'D':
			v -= 1
		elif s[i] == 'U':
			v += 1
		k = str(h) + ',' + str(v)
		if k in a:
			if i - a[k] < right - left:
				left = a[k] + 1
				right = i + 1
		a[k] = i + 1
	if left == -1:
		print('-1')
	else:
		print(left, right)


def move(pos, d):
	(x, y) = (pos[0], pos[1])
	if d == 'L':
		x -= 1
	elif d == 'R':
		x += 1
	elif d == 'U':
		y += 1
	elif d == 'D':
		y -= 1
	return (x, y)
t = int(input())
for case in range(t):
	n = int(input())
	moves = str(input())
	pos_dict = {(0, 0): 0}
	cur_pos = [0, 0]
	cur_min = 200005
	cur_solution = [None, None]
	for i in range(n):
		m = moves[i]
		cur_pos = move(cur_pos, m)
		if cur_pos not in pos_dict:
			pos_dict[cur_pos] = i + 1
		else:
			candidate = [pos_dict[cur_pos] + 1, i + 1]
			if candidate[1] - candidate[0] < cur_min:
				cur_solution = candidate
				cur_min = candidate[1] - candidate[0]
			pos_dict[cur_pos] = i + 1
	if cur_solution == [None, None]:
		print(-1)
	else:
		print(*cur_solution)


from collections import defaultdict
t = int(input())
for _ in range(t):
	n = int(input())
	s = input()
	Dict = defaultdict(list)
	x = [0, 0]
	y = (0, 0)
	Dict[y] = [1, -1]
	ans = []
	for i in range(n):
		if s[i] == 'R':
			a = x[0] + 1
			b = x[1]
			if len(Dict[a, b]) == 0:
				Dict[a, b] = [1, i]
			else:
				a1 = Dict[a, b][1]
				Dict[a, b] = [1, i]
				ans.append([i - a1, a1 + 1, i])
		elif s[i] == 'L':
			a = x[0] - 1
			b = x[1]
			if len(Dict[a, b]) == 0:
				Dict[a, b] = [1, i]
			else:
				a1 = Dict[a, b][1]
				Dict[a, b] = [1, i]
				ans.append([i - a1, a1 + 1, i])
		elif s[i] == 'U':
			a = x[0]
			b = x[1] + 1
			if len(Dict[a, b]) == 0:
				Dict[a, b] = [1, i]
			else:
				a1 = Dict[a, b][1]
				Dict[a, b] = [1, i]
				ans.append([i - a1, a1 + 1, i])
		elif s[i] == 'D':
			a = x[0]
			b = x[1] - 1
			if len(Dict[a, b]) == 0:
				Dict[a, b] = [1, i]
			else:
				a1 = Dict[a, b][1]
				Dict[a, b] = [1, i]
				ans.append([i - a1, a1 + 1, i])
		x = [a, b]
	ans.sort()
	if len(ans) == 0:
		print(-1)
	else:
		print(ans[0][1] + 1, ans[0][2] + 1)


def getInput():
	return input().strip()
X_ = {'L': -1, 'R': 1, 'U': 0, 'D': 0}
Y_ = {'L': 0, 'R': 0, 'U': 1, 'D': -1}
T = int(getInput())
for _ in range(T):
	N = int(getInput())
	S = getInput()
	pos = (0, 0)
	occured = {}
	occured[pos] = 0
	shortest = (0, 1000000000)
	shortestD = shortest[1] - shortest[0]
	for i in range(len(S)):
		c = S[i]
		newpos = (pos[0] + X_[c], pos[1] + Y_[c])
		if newpos in occured.keys():
			lastOcc = occured[newpos]
			if i - lastOcc < shortestD:
				shortestD = i - lastOcc
				shortest = (lastOcc, i)
		occured[newpos] = i + 1
		pos = newpos
	if shortestD == 1000000000:
		print(-1)
	else:
		print(shortest[0] + 1, shortest[1] + 1)