#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    string s;
    cin >> n >> s;
    map<pair<int, int>, int> m;
    m[{0, 0}] = 0;
    long long ansDist = 100000000000000000LL;
    pair<int, int> ans;
    ans = {0, 0};
    int x = 0, y = 0;
    for (int i = 1; i <= s.size(); i++) {
      if (s[i - 1] == 'L') x--;
      if (s[i - 1] == 'R') x++;
      if (s[i - 1] == 'D') y--;
      if (s[i - 1] == 'U') y++;
      pair<int, int> ind;
      ind = {x, y};
      if (m.count(ind) != 0) {
        int val = m[ind];
        int dist = i - val;
        if (dist < ansDist) {
          ansDist = dist;
          ans = {val + 1, i};
        }
      }
      m[ind] = i;
    }
    if (ans.first == 0)
      cout << -1 << endl;
    else
      cout << ans.first << " " << ans.second << endl;
  }
}
