#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  scanf("%d", &t);
  for (int i = 0; i < t; i++) {
    int x, y, n, cnt = 0, chk = 0, tmp, pos = -1, pos2 = -1, res;
    map<pair<int, int>, int> mp, Tmp, Imp;
    map<int, string> mp2;
    string s = "", s2 = "", s3 = "";
    scanf("%d", &n);
    cin >> s;
    x = 0, y = 0;
    Tmp[{x, y}]++;
    mp[{x, y}]++;
    for (int j = 0; j < s.size(); j++) {
      s2 = "", s3 = "";
      if (s[j] == 'U') {
        y++;
      } else if (s[j] == 'D') {
        y--;
      } else if (s[j] == 'R') {
        x++;
      } else if (s[j] == 'L') {
        x--;
      }
      if (j == 0) {
        int tx = x, ty = y;
      }
      tmp = mp[{x, y}];
      mp[{x, y}]++;
      if (j == 0) {
        Imp[{x, y}] = j;
      }
      if (mp[{x, y}] != tmp && tmp != 0) {
        int dist;
        if (x == 0 && y == 0 && pos == -1 && pos2 == -1) {
          dist = abs((j + 1) - (Imp[{x, y}] + 1));
        } else {
          dist = abs((j + 1) - (Imp[{x, y}] + 2));
        }
        chk++;
        if (chk == 1 || dist < res) {
          res = dist;
          if (x == 0 && y == 0 && pos == -1 && pos2 == -1) {
            pos2 = Imp[{x, y}] + 1;
            pos = j + 1;
          } else {
            pos2 = Imp[{x, y}] + 2;
            pos = j + 1;
          }
        }
      }
      if (j != 0) {
        Imp[{x, y}] = j;
      }
    }
    if (chk == 0) {
      printf("-1\n");
    } else {
      printf("%d %d\n", min(pos, pos2), max(pos, pos2));
    }
  }
  return 0;
}
