#include <bits/stdc++.h>
void Print(long long int n) { printf("%lld\n", n); }
const long long int Mod = 1e9 + 7, MX = 1e7;
using namespace std;
struct R {
  long long int x, y, st;
};
bool cmp(R a, R b) {
  if (a.x != b.x) return a.x < b.x;
  if (a.y != b.y) return a.y < b.y;
  return a.st < b.st;
}
int main() {
  char s[200005];
  long long int n, m, i, j, k, cs = 1;
  scanf("%*d");
  while (~scanf("%lld %s", &n, s)) {
    vector<R> v;
    long long int x = 0, y = 0, st = 1, c;
    v.push_back({x, y, st});
    for (i = 0; i < n; i++) {
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
      if (s[i] == 'U') y++;
      if (s[i] == 'D') y--;
      v.push_back({x, y, ++st});
    }
    sort(v.begin(), v.end(), cmp);
    long long int l, r, mn = 1e9;
    x = v[0].x, y = v[0].y, st = v[0].st, c = 1;
    for (i = 1; i < v.size(); i++) {
      if (v[i - 1].x == v[i].x && v[i - 1].y == v[i].y) {
        if (mn > v[i].st - v[i - 1].st)
          mn = v[i].st - v[i - 1].st, l = v[i - 1].st, r = v[i].st - 1;
      }
    }
    if (mn == 1e9)
      puts("-1");
    else
      printf("%lld %lld\n", l, r);
  }
  return 0;
}
