#include <bits/stdc++.h>
using namespace std;
int moves[4][2] = {{-1, 0}, {0, 1}, {1, 0}, {0, -1}};
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<pair<int, int>, int> mapa;
  int mn = 1e9;
  int from = -1;
  int x, y;
  x = y = 0;
  mapa[{0, 0}] = 0;
  for (int i = 0; i < n; i++) {
    char c = s[i];
    int mv;
    if (c == 'L')
      mv = 0;
    else if (c == 'U')
      mv = 1;
    else if (c == 'R')
      mv = 2;
    else
      mv = 3;
    x += moves[mv][0];
    y += moves[mv][1];
    if (mapa.find({x, y}) != mapa.end()) {
      int first = mapa[{x, y}];
      if (i - first + 1 < mn) {
        mn = i - first + 1;
        from = first;
      }
    }
    mapa[{x, y}] = i + 1;
  }
  if (mn != 1e9)
    cout << from + 1 << " " << from + mn << "\n";
  else
    cout << "-1\n";
}
int main() {
  int t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    solve();
  }
}
