#include <bits/stdc++.h>
using namespace std;
int main() {
  int q;
  cin >> q;
  while (q--) {
    int n;
    string s;
    map<pair<int, int>, int> mp;
    int ansl = -1, ansr = -1;
    cin >> n >> s;
    int r = 0, u = 0;
    int ans = INT_MAX;
    mp[make_pair(0, 0)] = -1;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'L') {
        r--;
      } else if (s[i] == 'R') {
        r++;
      } else if (s[i] == 'U') {
        u++;
      } else if (s[i] == 'D') {
        u--;
      }
      if (mp.count(make_pair(r, u))) {
        int tmp = i - mp[make_pair(r, u)];
        if (tmp < ans) {
          ans = tmp;
          ansl = mp[make_pair(r, u)] + 1;
          ansr = i;
        }
      }
      mp[make_pair(r, u)] = i;
    }
    if (ans != INT_MAX) {
      cout << ansl + 1 << ' ' << ansr + 1 << '\n';
    } else {
      cout << -1 << '\n';
    }
  }
  return 0;
}
