#include <bits/stdc++.h>
using namespace std;
struct ppp {
  int x;
  int y;
  int ind;
  bool operator<(const ppp& el) const {
    return ((x < el.x) || (x == el.x && y < el.y) ||
            (x == el.x && y == el.y && ind < el.ind));
  }
};
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<ppp> v(n + 1);
  v[0] = {0, 0, 0};
  for (int i = 0; i < n; i++) {
    v[i + 1].x = v[i].x;
    v[i + 1].y = v[i].y;
    if (s[i] == 'L') v[i + 1].x--;
    if (s[i] == 'R') v[i + 1].x++;
    if (s[i] == 'U') v[i + 1].y++;
    if (s[i] == 'D') v[i + 1].y--;
    v[i + 1].ind = i + 1;
  }
  int bestl = 1e9, bestr = 1e9;
  int res = 1e9;
  sort(v.begin(), v.end());
  for (int i = 0; i + 1 < v.size(); i++)
    if (v[i].x == v[i + 1].x && v[i].y == v[i + 1].y &&
        v[i + 1].ind - v[i].ind < res) {
      res = v[i + 1].ind - v[i].ind;
      bestl = v[i].ind;
      bestr = v[i + 1].ind;
    }
  if (res == 1e9) {
    cout << "-1\n";
    return;
  }
  cout << (bestl + 1) << " " << bestr << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  int t;
  cin >> t;
  for (; t; t--) solve();
}
