#include <bits/stdc++.h>
using namespace std;
void solve(string s, int n) {
  unordered_map<string, int> m;
  pair<int, int> res;
  m["0,0"] = -1;
  int minv = INT_MAX;
  int v = 0, h = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'L') {
      h--;
    } else if (s[i] == 'R') {
      h++;
    } else if (s[i] == 'U') {
      v++;
    } else {
      v--;
    }
    string k = to_string(v) + ',' + to_string(h);
    if (m.count(k)) {
      int dis = i - m[k];
      if (dis < minv) {
        minv = dis;
        res = make_pair(m[k] + 2, i + 1);
      }
    }
    m[k] = i;
  }
  if (minv == INT_MAX)
    cout << -1 << endl;
  else
    cout << res.first << ' ' << res.second << endl;
}
int main() {
  int t, n;
  cin >> t;
  string s;
  for (int i = 0; i < t; ++i) {
    cin >> n;
    cin >> s;
    solve(s, n);
  }
  return 0;
}
