#include <bits/stdc++.h>
using namespace std;
struct abc {
  long long int x, y;
};
bool compare(abc a1, abc a2) {
  if (a1.x == a2.x) return a1.y < a2.y;
  return a1.x < a2.x;
}
const long long int mod = 1e9 + 7;
long long int a[200005], b[200005];
int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t;
  cin >> t;
  while (t--) {
    long long int n, x = 0, y = 0, ans = 2e6, a = 0, b = 0;
    string s;
    cin >> n >> s;
    map<pair<long long int, long long int>, vector<long long int>> make_pair;
    make_pair[{0, 0}].push_back(0);
    for (long long int i = 0; i < n; i++) {
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
      if (s[i] == 'D') y--;
      if (s[i] == 'U') y++;
      if (make_pair.count({x, y})) {
        long long int a1 = i + 1, b1 = make_pair[{x, y}].back() + 1;
        if (ans > a1 - b1 + 1) {
          ans = a1 - b1 + 1;
          a = a1, b = b1;
        }
      }
      make_pair[{x, y}].push_back(i + 1);
    }
    if (a == 0 && b == 0)
      cout << -1 << endl;
    else
      cout << b << ' ' << a << endl;
  }
}
