#include <bits/stdc++.h>
using namespace std;
map<pair<long long, long long>, long long> m;
int main() {
  ios::sync_with_stdio(false);
  long long t;
  cin >> t;
  while (t--) {
    m.clear();
    long long n;
    string s;
    cin >> n >> s;
    s = '#' + s;
    pair<long long, long long> p = {0, 0}, k = {0, 1e9};
    m[p] = 1;
    for (int i = 1; i <= n; i++) {
      if (s[i] == 'R')
        p.first++;
      else if (s[i] == 'L')
        p.first--;
      else if (s[i] == 'U')
        p.second++;
      else
        p.second--;
      if (m[p] != 0) {
        if (i - m[p] < k.second - k.first) {
          k = {m[p], i};
        }
      }
      m[p] = i + 1;
    }
    if (k.second == 1e9)
      cout << -1 << endl;
    else
      cout << k.first << " " << k.second << endl;
  }
  return 0;
}
