#include <bits/stdc++.h>
using namespace std;
const int MAXN = 200005;
const int INF = 1 << 30;
char s[MAXN];
map<pair<int, int>, int> pos;
int T, n, ans, l, r;
int main() {
  scanf("%d", &T);
  while (T--) {
    pair<int, int> now;
    now.first = now.second = 0;
    pos.clear();
    ans = INF;
    scanf("%d", &n);
    scanf("%s", s + 1);
    pos[make_pair(0, 0)] = 0;
    for (int i = 1; i <= n; ++i) {
      if (s[i] == 'L') --now.second;
      if (s[i] == 'R') ++now.second;
      if (s[i] == 'U') --now.first;
      if (s[i] == 'D') ++now.first;
      if (pos.find(now) != pos.end()) {
        if (ans > i - pos[now]) {
          l = pos[now];
          r = i;
          ans = r - l;
        }
      }
      pos[now] = i;
    }
    if (ans != INF) {
      printf("%d %d\n", l + 1, r);
    } else {
      printf("-1\n");
    }
  }
  return 0;
}
