#include <bits/stdc++.h>
#pragma GCC optimize(2)
using namespace std;
const int inf = 0x3f3f3f3f;
const long long INF = 0x3f3f3f3f3f3f3f3fLL;
const int maxn = 2e5 + 10;
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int t, n, L, R;
char s[maxn];
map<pair<int, int>, int> mp;
int main() {
  scanf("%d", &t);
  while (t--) {
    mp.clear();
    int ans = inf;
    bool flag = false;
    scanf("%d", &n);
    scanf("%s", s + 1);
    int num1 = 0, num2 = 0;
    pair<int, int> tmp = make_pair(0, 0);
    mp[tmp] = 0;
    for (int i = 1; i <= n; i++) {
      if (s[i] == 'L')
        num1--;
      else if (s[i] == 'R')
        num1++;
      else if (s[i] == 'D')
        num2--;
      else if (s[i] == 'U')
        num2++;
      tmp = make_pair(num1, num2);
      if (mp.find(tmp) == mp.end())
        mp[tmp] = i;
      else {
        flag = true;
        if (ans > i - mp[tmp]) {
          ans = i - mp[tmp];
          L = mp[tmp] + 1;
          R = i;
        }
        mp[tmp] = i;
      }
    }
    if (!flag)
      printf("%d\n", -1);
    else
      printf("%d %d\n", L, R);
  }
  return 0;
}
