#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long int n;
  cin >> n;
  string s;
  cin >> s;
  map<pair<int, int>, int> mk;
  long long int len = 1e9, ans1, ans2;
  long long int x = 0, y = 0;
  mk[{x, y}] = 1;
  for (long long int i = 0; i < int((s).size()); i++) {
    if (s[i] == 'L') {
      x--;
    }
    if (s[i] == 'R') {
      x++;
    }
    if (s[i] == 'U') {
      y++;
    }
    if (s[i] == 'D') y--;
    if (mk[{x, y}] != 0) {
      long long int q = i + 2 - mk[{x, y}];
      if (q < len) {
        len = q;
        ans1 = mk[{x, y}];
        ans2 = i + 1;
      }
    }
    mk[{x, y}] = i + 2;
  }
  if (len == 1e9) {
    cout << -1 << endl;
    return;
  }
  cout << ans1 << " " << ans2 << endl;
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  t = 1;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
