#include <bits/stdc++.h>
using namespace std;
void solve(long long* a, long long n, long long x) {
  map<long long, long long> mp;
  long long s = 0;
  long long ans = n + 1;
  mp[0] = -1;
  pair<long long, long long> tp;
  for (long long i = 0; i < n; i++) {
    s += a[i];
    if (mp.count(s)) {
      if ((i - mp[s]) < ans) {
        tp.first = mp[s] + 1, tp.second = i;
        ans = i - mp[s];
      }
    }
    mp[s] = i;
  }
  if (ans == (n + 1)) {
    cout << -1 << '\n';
    return;
  } else {
    cout << tp.first + 1 << " " << tp.second + 1 << endl;
  }
}
int32_t main() {
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    long long a[n];
    map<char, long long> mp = {
        {'U', INT_MAX}, {'D', -INT_MAX}, {'L', 1}, {'R', -1}};
    string s;
    cin >> s;
    for (long long i = 0; i < n; i++) {
      a[i] = mp[s[i]];
    }
    solve(a, n, 0);
  }
  return 0;
}
