#include <bits/stdc++.h>
using namespace std;
int main() {
  int t, n;
  char s[200050];
  map<int, map<int, int>> vis, cnt;
  scanf("%d", &t);
  while (t--) {
    vis.clear();
    cnt.clear();
    int l = -5, r = 0x3f3f3f3f;
    scanf("%d%s", &n, s);
    int x = 0, y = 0;
    vis[x][y] = 1;
    cnt[x][y] = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'L') {
        x -= 1;
      } else if (s[i] == 'R') {
        x += 1;
      } else if (s[i] == 'D') {
        y -= 1;
      } else {
        y += 1;
      }
      if (vis[x][y] && i - cnt[x][y] < r - l) {
        l = cnt[x][y] + 1;
        r = i + 1;
      }
      cnt[x][y] = i + 1;
      vis[x][y] = 1;
    }
    if (l != -5)
      printf("%d %d\n", l, r);
    else
      printf("-1\n");
  }
}
