#include <bits/stdc++.h>
using namespace std;
string s;
map<pair<int, int>, int> maps;
int main() {
  int t, len;
  scanf("%d", &t);
  while (t--) {
    maps.clear();
    scanf("%d", &len);
    cin >> s;
    s = "#" + s;
    int x = 0, y = 0, l = 0, r = 0;
    int minlen = 0x3f3f3f3f;
    pair<int, int> top;
    top = make_pair(0, 0);
    maps[top] = -1;
    for (int i = 1; i < s.length(); i++) {
      if (s[i] == 'L') {
        x--;
        top = make_pair(x, y);
        if (maps[top] == 0)
          maps[top] = i;
        else {
          if (x == 0 && y == 0 && maps[top] == -1) maps[top] = 0;
          if (minlen > i - maps[top] + 1) {
            l = maps[top];
            r = i;
            minlen = i - maps[top] + 1;
          }
          maps[top] = i;
        }
      } else if (s[i] == 'R') {
        x++;
        top = make_pair(x, y);
        if (maps[top] == 0)
          maps[top] = i;
        else {
          if (x == 0 && y == 0 && maps[top] == -1) maps[top] = 0;
          if (minlen > i - maps[top] + 1) {
            l = maps[top];
            r = i;
            minlen = i - maps[top] + 1;
          }
          maps[top] = i;
        }
      } else if (s[i] == 'U') {
        y++;
        top = make_pair(x, y);
        if (maps[top] == 0)
          maps[top] = i;
        else {
          if (x == 0 && y == 0 && maps[top] == -1) maps[top] = 0;
          if (minlen > i - maps[top] + 1) {
            l = maps[top];
            r = i;
            minlen = i - maps[top] + 1;
          }
          maps[top] = i;
        }
      } else if (s[i] == 'D') {
        y--;
        top = make_pair(x, y);
        if (maps[top] == 0)
          maps[top] = i;
        else {
          if (x == 0 && y == 0 && maps[top] == -1) maps[top] = 0;
          if (minlen > (i - maps[top] + 1)) {
            l = maps[top];
            r = i;
            minlen = i - maps[top] + 1;
          }
          maps[top] = i;
        }
      }
    }
    if (minlen == 0x3f3f3f3f)
      cout << "-1" << endl;
    else {
      cout << l + 1 << " " << r << endl;
    }
  }
  return 0;
}
