#include <bits/stdc++.h>
using namespace std;
struct co {
  int l;
  int d;
  int i;
} mas[200001];
bool cmp(co a, co b) {
  if (a.l != b.l) return a.l < b.l;
  if (a.d != b.d) return a.d < b.d;
  return a.i < b.i;
}
int main() {
  long long t;
  cin >> t;
  for (int step = 0; step < t; step++) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < n; i++) {
      if (i == 0) {
        mas[i].l = 0;
        mas[i].d = 0;
        mas[i].i = 0;
        if (s[i] == 'L') mas[i].l++;
        if (s[i] == 'R') mas[i].l--;
        if (s[i] == 'D') mas[i].d--;
        if (s[i] == 'U') mas[i].d++;
      } else {
        mas[i].l = mas[i - 1].l;
        mas[i].d = mas[i - 1].d;
        mas[i].i = i;
        if (s[i] == 'L') mas[i].l++;
        if (s[i] == 'R') mas[i].l--;
        if (s[i] == 'D') mas[i].d--;
        if (s[i] == 'U') mas[i].d++;
      }
    }
    mas[n].l = 0;
    mas[n].d = 0;
    mas[n].i = -1;
    sort(mas, mas + n + 1, cmp);
    int a = 0, b = 0, ans = n + 1;
    for (int i = 1; i < n + 1; i++) {
      if (mas[i].l == mas[i - 1].l && mas[i].d == mas[i - 1].d) {
        if (mas[i].i - mas[i - 1].i < ans) {
          a = mas[i - 1].i + 1;
          b = mas[i].i;
          ans = mas[i].i - mas[i - 1].i;
        }
      }
    }
    if (ans == n + 1)
      cout << -1 << endl;
    else
      cout << a + 1 << ' ' << b + 1 << endl;
  }
  return 0;
}
