#include <bits/stdc++.h>
using namespace std;
char ch[200001];
int main() {
  int t;
  scanf("%d", &t);
  while (t--) {
    int n, mn = 1e9, fir, sec;
    map<pair<int, int>, int> mp;
    scanf("%d%s", &n, ch);
    pair<int, int> p;
    p = {0, 0};
    mp[p] = 1;
    for (int i = 0; i < n; i++) {
      if (ch[i] == 'L')
        p.first--;
      else if (ch[i] == 'R')
        p.first++;
      else if (ch[i] == 'U')
        p.second++;
      else
        p.second--;
      if (mp[p] && i + 2 - mp[p] < mn) {
        fir = mp[p];
        sec = i + 2;
        mn = i + 2 - mp[p];
      }
      mp[p] = i + 2;
    }
    if (mn == 1e9)
      printf("-1\n");
    else
      printf("%d %d\n", fir, sec - 1);
  }
  return 0;
}
