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
[{"code": "for _ in range(int(input())):\n    n = int(input())\n    s = input()\n    balance = 0\n    index = {0: 1}\n    ans = [10**9]\n    i = 1\n    for x in s:\n        if x == 'U':\n            balance += 10 ** 9\n        elif x == 'D':\n            balance -= 10 ** 9\n        elif x == 'L':\n            balance += 1\n        else:\n            balance -= 1\n        if balance in index:\n            ans = min(ans, [i + 1 - index[balance], index[balance], i])\n        index[balance] = i + 1\n        i += 1\n    if ans[0] == 10 ** 9:\n        print(-1)\n    else:\n        print(ans[1], ans[2])\n", "passed": true, "time": 0.14, "memory": 14156.0, "status": "done"}, {"code": "from sys import stdin\ninput = stdin.readline\nq = int(input())\nN = 2342379478943\nfor rwwe in range(q):\n\tn = int(input())\n\ts = input()\n\tk = []\n\tfor i in range(n):\n\t\tif s[i] == \"L\":\n\t\t\tk.append(1)\n\t\tif s[i] == \"R\":\n\t\t\tk.append(-1)\n\t\tif s[i] == \"U\":\n\t\t\tk.append(N)\n\t\tif s[i] == \"D\":\n\t\t\tk.append(-N)\n\tpref = [0] * (n+1)\n\tfor i in range(1,n+1):\n\t\tpref[i] = pref[i-1] + k[i-1]\n\t#print(pref)############\n\td = {}\n\tfor i in pref:\n\t\td[i] = []\n\tfor i in range(len(pref)):\n\t\td[pref[i]].append(i)\n\tbest = 10000000000\n\todp = [\"a\",\"a\"]\n\t#print(d)##########\n\tfor i in d:\n\t\tif len(d[i]) < 2:\n\t\t\tcontinue\n\t\telse:\n\t\t\tfor j in range(1,len(d[i])):\n\t\t\t\tif d[i][j]-d[i][j-1] < best:\n\t\t\t\t\tbest = d[i][j]-d[i][j-1]\n\t\t\t\t\todp = [d[i][j-1]+1,d[i][j]]\n\tif odp != [\"a\",\"a\"]:\n\t\tprint(*odp)\n\telse:\n\t\tprint(-1)\n", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\nfrom collections import defaultdict\n\nt=int(input())\nfor tests in range(t):\n    n=int(input())\n    S=input().strip()\n\n    ANS=1<<31\n    D=defaultdict(list)\n\n    NOW=[0,0]\n    TIME=0\n    D[tuple(NOW)].append(TIME)\n    TIME+=1\n\n    for s in S:\n        if s==\"U\":\n            NOW[0]+=1\n        elif s==\"D\":\n            NOW[0]-=1\n        elif s==\"R\":\n            NOW[1]+=1\n        else:\n            NOW[1]-=1\n\n        D[tuple(NOW)].append(TIME)\n        TIME+=1\n\n        if len(D[tuple(NOW)])>1 and ANS>D[tuple(NOW)][-1]-D[tuple(NOW)][-2]:\n            ANS=D[tuple(NOW)][-1]-D[tuple(NOW)][-2]\n            ANSX=(D[tuple(NOW)][-2]+1,D[tuple(NOW)][-1])\n\n    if ANS==1<<31:\n        print(-1)\n    else:\n        print(*ANSX)\n                \n            \n            \n            \n\n    \n    \n", "passed": true, "time": 0.23, "memory": 14320.0, "status": "done"}, {"code": "t = int(input())\nfor _ in range(t):\n\tn = int(input())\n\ts = input()\n\n\tposition_to_step = {(0, 0): 0}\n\tlen_of_min = n+1\n\tans = (0, 0)\n\tpos = (0, 0)\n\n\tfor i in range(n):\n\t\titem = s[i]\n\t\tif  item == \"U\":\n\t\t\tpos = (pos[0], pos[1]+1)\n\t\telif  item == \"D\":\n\t\t\tpos = (pos[0], pos[1]-1)\n\t\tif  item == \"R\":\n\t\t\tpos = (pos[0]+1, pos[1])\n\t\tif  item == \"L\":\n\t\t\tpos = (pos[0]-1, pos[1])\n\n\t\tif pos in position_to_step:\n\t\t\tif i - position_to_step[pos] < len_of_min:\n\t\t\t\tlen_of_min = i - position_to_step[pos]\n\t\t\t\tans = position_to_step[pos], i\n\n\t\tposition_to_step[pos] = i+1\n\n\tif ans[0] == ans[1]:\n\t\tprint(-1)\n\telse:\n\t\tprint(ans[0]+1, ans[1]+1)\n", "passed": true, "time": 0.24, "memory": 14324.0, "status": "done"}, {"code": "import sys\n\n# inf = open('input.txt', 'r')\n# reader = (line.rstrip() for line in inf)\nreader = (line.rstrip() for line in sys.stdin)\ninput = reader.__next__\n\nt = int(input())\nfor _ in range(t):\n    n = int(input())\n    coms = list(input())\n    pos = {(0, 0):-1}\n    x = y = 0\n    l = -1\n    r = float('inf')\n    for i, d in enumerate(coms):\n        if d == 'L':\n            x -= 1\n        elif d == 'R':\n            x += 1\n        elif d == 'U':\n            y += 1\n        else:\n            y -= 1\n        \n        if (x, y) in pos:\n            prev = pos[(x, y)]\n            if i - prev < r - l:\n                r, l = i, prev\n        pos[(x, y)] = i\n    \n    if r == float('inf'):\n        print(-1)\n    else:\n        print(l + 2, r + 1)\n\n# inf.close()\n", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n = int(input())\n    ar = list(input())\n    left, right = 0, 0\n    kek = [[0, 0, 0]]\n    for i in range(n):\n        elem = ar[i]\n        if elem == 'L':\n            left -= 1\n        elif elem == 'R':\n            left += 1\n        elif elem == 'U':\n            right += 1\n        else:\n            right -= 1\n        kek.append([left, right, i + 1])\n    kek.sort()\n    ans = 10 ** 9\n    a, b = -1, -1\n    for i in range(n + 1):\n        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:\n            ans = kek[i][2] - kek[i - 1][2]\n            a, b = kek[i - 1][2] + 1, kek[i][2]\n    if a == b == -1:\n        print(-1)\n    else:\n        print(a, b)", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "from collections import Counter\nt = int(input())\ninf = 10**18\nfor _ in range(t):\n    n = int(input())\n    s = input()\n    ans = [inf, 0, 0]\n    cnt = Counter({(0, 0): 1})\n    x, y = 0, 0\n\n    for i, c in enumerate(s, start=1):\n        if c == 'L':\n            x -= 1\n        elif c == 'R':\n            x += 1\n        elif c == 'U':\n            y -= 1\n        else:\n            y += 1\n        if (x, y) in cnt and i - cnt[(x, y)] < ans[0]:\n            ans[0] = i - cnt[(x, y)]\n            ans[1], ans[2] = cnt[(x, y)], i\n        cnt[(x, y)] = i+1\n\n    if ans[0] < inf:\n        print(ans[1], ans[2])\n    else:\n        print(-1)\n", "passed": true, "time": 0.71, "memory": 14268.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\ndef getInt(): return int(input())\ndef getVars(): return list(map(int, input().split()))\ndef getList(): return list(map(int, input().split()))\ndef getStr(): return input().strip()\n## -------------------------------\n\n\n\nt = getInt()\nfor _ in range(t):\n    n = getInt()\n    s = getStr()\n    d = {}\n    d['0/0'] = 0\n    x = 0\n    y = 0\n    res = [0, n+1]\n    for i in range(n):\n        if s[i] == 'L':\n            x -= 1\n        if s[i] == 'R':\n            x += 1\n        if s[i] == 'U':\n            y += 1\n        if s[i] == 'D':\n            y -= 1\n        k = str(x) + '/' + str(y)\n        if k not in d:\n            d[k] = i+1\n        else:\n            if i+1 - d[k] < res[1] - res[0]:\n                res = [d[k]+1, i+1]\n            d[k] = i+1\n    if res[1] == n+1:\n        print(-1)\n    else:\n        print(*res)\n    \n", "passed": true, "time": 0.24, "memory": 14324.0, "status": "done"}, {"code": "\n\n\n\n\n\n\n\nimport sys\ninput=sys.stdin.readline\n\nt=int(input())\nfor _ in range(t):\n    n=int(input())\n    it=list(input())\n    ss={}\n    x=0\n    y=0\n    ss[(0,0)]=-1\n    mi=n+1\n    ans=[]\n    for i in range(n):\n        if it[i]==\"L\":\n            x-=1\n        elif it[i]==\"R\":\n            x+=1\n        elif it[i]==\"U\":\n            y+=1\n        else:\n            y-=1\n       # if x==0 and y==0:\n        #    print(_)\n       # print(x,y)\n        try:\n            xx=ss[(x,y)]\n            if i+1-xx-2+1<mi:\n                mi=i+1-xx-2+1\n                ans=[xx+2,i+1]\n        except:\n            pass\n        ss[(x,y)]=i\n    if ans==[]:\n        print(-1)\n        continue\n    print(*ans)\n", "passed": true, "time": 0.14, "memory": 14256.0, "status": "done"}, {"code": "\nt = int(input())\n\nfor loop in range(t):\n\n    n = int(input())\n\n    s = input()\n\n    x = 0\n    y = 0\n\n    dic = {}\n    dic[(0,0)] = -1\n\n    ansl = float(\"-inf\")\n    ansr = float(\"inf\")\n\n    for i,S in enumerate(s):\n\n        if S == \"L\":\n            x -= 1\n        elif S == \"R\":\n            x += 1\n        elif S == \"U\":\n            y += 1\n        elif S == \"D\":\n            y -= 1\n\n        if (x,y) in dic:\n            nowl = dic[(x,y)]\n            nowr = i\n\n            if nowr - nowl < ansr - ansl:\n                ansl = nowl\n                ansr = nowr\n            \n        dic[(x,y)] = i\n\n    if ansr == float(\"inf\"):\n        print(-1)\n    else:\n        print(ansl+2,ansr+1)\n       \n", "passed": true, "time": 0.14, "memory": 14280.0, "status": "done"}, {"code": "t = int(input())\nfor y in range(t):\n\tn = int(input())\n\ts = input()\n\tpre = [0 for i in range(n+1)]\n\tfor i in range(n):\n\t\tif(s[i] == 'L'): pre[i+1] = pre[i]+1\n\t\telif(s[i] == 'R'): pre[i+1] = pre[i]-1\n\t\telif(s[i] == 'U'): pre[i+1] = pre[i]+int(1e6)\n\t\telse: pre[i+1] = pre[i]-int(1e6)\n\t#print(pre)\n\td = dict()\n\tans = -1\n\tl = r = -1\n\tfor i in range(n+1):\n\t\tif pre[i] not in d:\n\t\t\td[pre[i]] = i\n\t\telse:\n\t\t\tif ans == -1 or i - d[pre[i]] < ans:\n\t\t\t\tans  = i - d[pre[i]]\n\t\t\t\tl = d[pre[i]]+1\n\t\t\t\tr = i\n\t\t\td[pre[i]] = i\n\tif(ans == -1): print(ans)\n\telse: print(l,r)\n", "passed": true, "time": 0.14, "memory": 14120.0, "status": "done"}, {"code": "def one():\n    return int(input())\n\n\ndef two():\n    return list(map(int, input().split()))\n\n\ndef lis():\n    return list(map(int, input().split()))\n\n\ndef st():\n    return input()\n\n\nfor i in range(one()):\n    input()\n    d = {(0, 0): 0}\n    s = st()\n    c = [0, 0]\n    r = 0\n    m = float('inf')\n    ans = None\n    for j in s:\n        if j == 'U':\n            c[1] += 1\n        if j == 'D':\n            c[1] -= 1\n        if j == 'R':\n            c[0] += 1\n        if j == 'L':\n            c[0] -= 1\n        r += 1\n        if (c[0], c[1]) in d:\n            if m > r - d[(c[0], c[1])] + 1:\n                ans = (d[(c[0], c[1])] + 1, r)\n                m = r - d[(c[0], c[1])] + 1\n            d[(c[0], c[1])] = r\n        else:\n            d[(c[0], c[1])] = r\n    if not ans:\n        print(-1)\n    else:\n        print(*ans)\n", "passed": true, "time": 0.22, "memory": 14364.0, "status": "done"}, {"code": "from collections import defaultdict\nimport sys\ninput = sys.stdin.readline\ndef case():\n    n = int(input())\n    s = input().strip()\n    t = 1\n    x, y = 0, 0\n    d = defaultdict(list)\n    d[(0, 0)].append(0)\n    anslen = 10**10\n    ans = []\n    for i in s:\n        if i == 'L':\n            x-=1\n        elif i == 'R':\n            x+=1\n        elif i == 'D':\n            y-=1\n        elif i == 'U':\n            y+=1\n        if d[(x, y)] != []:\n            if t-d[(x, y)][-1] < anslen:\n                anslen = t-d[(x, y)][-1]\n                ans = [d[(x, y)][-1], t]\n        d[(x, y)].append(t)\n        t+=1\n    if anslen == 10**10:\n        print(-1)\n    else:\n        print(ans[0]+1, ans[1])\nfor _ in range(int(input())):\n    case()", "passed": true, "time": 0.14, "memory": 14168.0, "status": "done"}, {"code": "import sys\ninput = sys.stdin.readline\n\ndx = [-1, 1, 0, 0]\ndy = [0, 0, 1, -1]\nR = {'L' : 0, 'R' : 1, 'U' : 2, 'D' : 3}\n\nT = int(input())\n\nfor _ in range(T):\n    x = y = 0\n    N = int(input())\n    Path = input().rstrip()\n\n    vst = {(0, 0) : 0}\n    ans = []\n    for i in range(N):\n        #print(x, y)\n        r = R[Path[i]]\n        x += dx[r]\n        y += dy[r]\n        if (x, y) in vst:\n            w = i - vst[(x, y)]\n            ans.append((w, vst[(x, y)] + 1, i + 1))\n\n        vst[(x, y)] = i + 1\n    ans.sort()\n\n    if ans:\n        print(ans[0][1], ans[0][2])\n    else:\n        print(-1)\n\n\n", "passed": true, "time": 0.14, "memory": 14332.0, "status": "done"}, {"code": "for _ in range(int(input())):\n    n = int(input())\n    s = list(input())\n    d1 = {}\n    d1[(0, 0)] = [0]\n    x, y = 0, 0\n    i = 1\n    for c in s:\n        if c ==\"L\":\n            x-=1\n        if c==\"R\":\n            x+=1\n        if c==\"U\":\n            y+=1\n        if c==\"D\":\n            y-=1\n        if (x,y) in d1:\n            d1[(x, y)].append(i)\n        else :\n            d1[(x,y)] = [i]\n        i+=1\n    answer = -1\n    answer_coord = [0, 0]\n    for x in d1:\n        if len(d1[x]) > 1:\n            d1[x].sort()\n            for i in range(len(d1[x]) - 1):\n                if answer == -1:\n                    answer = d1[x][i+1] - d1[x][i]\n                    answer_coord = [d1[x][i+1], d1[x][i]]\n                elif d1[x][i+1] - d1[x][i] < answer:\n                    answer = d1[x][i+1] - d1[x][i]\n                    answer_coord = [d1[x][i+1], d1[x][i]]\n    a = answer_coord[1]\n    b = answer_coord[0]\n    if answer!=-1:\n        print(a + 1, b)\n    else :\n        print(-1)", "passed": true, "time": 0.22, "memory": 14276.0, "status": "done"}, {"code": "for i in range(int(input())):\n\tn = int(input())\n\ts = input()\n\td = {}\n\tx = 0\n\ty = 0\n\td[(x,y)] = [0]\n\tm1 = -1\n\tm2 = -1\n\tc = 0\n\tfor i in s:\n\t\tc+=1\n\t\tif(i==\"L\"):\n\t\t\tx-=1\n\t\telif(i==\"R\"):\n\t\t\tx+=1\n\t\telif(i==\"U\"):\n\t\t\ty+=1\n\t\telse:\n\t\t\ty-=1\n\t\ttry:\n\t\t\td[(x, y)].append(c)\n\t\t\tif(m1==-1):\n\t\t\t\tm2 = d[(x, y)][-1]\n\t\t\t\tm1 = d[(x, y)][-2]\n\t\t\tif(d[(x, y)][-1] - d[(x, y)][-2])<(m2 - m1):\n\t\t\t\tm2 = d[(x, y)][-1]\n\t\t\t\tm1 = d[(x, y)][-2]\n\t\texcept:\n\t\t\td[(x,y)] = [c]\n\t#print(d)\n\tif(m1!=-1):\n\t\tprint(str(m1+1)+\" \"+str(m2))\n\telse:\n\t\tprint(-1)", "passed": true, "time": 0.14, "memory": 14296.0, "status": "done"}, {"code": "t = int(input())\n\nwhile t:\n    t -= 1\n    n = int(input())\n    s = list(input())\n    a = [(-1 if s[i] == 'L' else (1 if s[i] == 'R' else 0)) for i in range(n)]\n    b = [(-1 if s[i] == 'D' else (1 if s[i] == 'U' else 0)) for i in range(n)]\n    suma = [a[0] for _ in range(n)]\n    sumb = [b[0] for _ in range(n)]\n    d = dict()\n    d[(0, 0)] = -1\n    for i in range(1, n):\n        suma[i] = suma[i - 1] + a[i]\n        sumb[i] = sumb[i - 1] + b[i]\n    res = n + 1\n    _res = -1\n    for i in range(n):\n        #print(suma[i], sumb[i])\n        if (suma[i], sumb[i]) in d.keys():\n            if res > i - d[(suma[i], sumb[i])]:\n                res = i - d[(suma[i], sumb[i])]\n                _res = (d[(suma[i], sumb[i])], i)\n        d[(suma[i], sumb[i])] = i\n    if (_res == -1):\n        print(_res)\n    else:\n        print(_res[0] + 2, _res[1] + 1) ", "passed": true, "time": 0.14, "memory": 14272.0, "status": "done"}]