#include <bits/stdc++.h>
using namespace std;
const long long INF = (1e9 + 7);
const int nn = 1e5 + 7;
void solve() {
  map<pair<int, int>, int> path;
  int x = 0, y = 0;
  string s;
  int n;
  cin >> n;
  cin >> s;
  int i = 1, mx = 0, ansa = INF, ansb = 0;
  path[make_pair(0, 0)] = 0;
  for (char c : s) {
    if (c == 'R') {
      x++;
    } else if (c == 'L') {
      x--;
    } else if (c == 'U') {
      y++;
    } else {
      y--;
    }
    if (path.count(make_pair(x, y))) {
      int now = path[make_pair(x, y)];
      if (i - now < ansa - ansb) {
        ansb = now;
        ansa = i;
      }
      path[make_pair(x, y)] = i;
    } else {
      path[make_pair(x, y)] = i;
    }
    i++;
  }
  if (ansa == INF) {
    cout << -1 << '\n';
    return;
  }
  cout << ansb + 1 << ' ' << ansa << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int testcase = 1;
  cin >> testcase;
  for (int i = 0; i < testcase; i++) {
    solve();
  }
  return 0;
}
