#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<int, int>, int> ma;
    int x = 0, y = 0;
    int ans = n + 1;
    ma[{0, 0}] = 0;
    int l, r;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'L')
        y--;
      else if (s[i] == 'R')
        y++;
      else if (s[i] == 'U')
        x--;
      else
        x++;
      if (ma.find({x, y}) != ma.end()) {
        int temp = i - ma[{x, y}] + 1;
        if (temp < ans) {
          l = ma[{x, y}] + 1;
          r = i + 1;
          ans = temp;
        }
      }
      ma[{x, y}] = i + 1;
    }
    if (ans == n + 1)
      cout << (-1) << '\n';
    else
      cout << l << ' ' << r << '\n';
  }
  return 0;
}
