#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    map<pair<int, int>, int> m;
    map<int, pair<int, int>> res;
    pair<int, int> p(0, 0);
    m.insert(make_pair(p, 0));
    int j = 1;
    while (n--) {
      char a;
      cin >> a;
      if (a == 'L') {
        p.first--;
      } else if (a == 'R') {
        p.first++;
      } else if (a == 'U') {
        p.second++;
      } else {
        p.second--;
      }
      if (m.count(p)) {
        res.insert(make_pair((j - 1) - m.find(p)->second + 1,
                             make_pair(m.find(p)->second + 1, j)));
      }
      m[p] = j;
      j++;
    }
    if (res.begin() != res.end()) {
      if (res.begin()->second.first != 0) {
        cout << res.begin()->second.first << " " << res.begin()->second.second
             << "\n";
      } else {
        cout << 1 << " " << res.begin()->second.second << "\n";
      }
    } else {
      cout << -1 << "\n";
    }
  }
  return 0;
}
