#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
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;
    int sz = (int)s.size();
    int x = 0, y = 0;
    int ans = INF;
    map<pair<int, int>, int> xd;
    int comeca = -1, termina = -1;
    xd[{0, 0}] = 0;
    for (int i = 0; i < sz; i++) {
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
      if (s[i] == 'U') y++;
      if (s[i] == 'D') y--;
      if (xd.count({x, y})) {
        int z = (i + 1) - xd[{x, y}];
        if (z < ans) {
          comeca = xd[{x, y}] + 1;
          termina = i + 1;
          ans = z;
        }
      }
      xd[{x, y}] = i + 1;
    }
    if (comeca != -1 && termina != -1) {
      cout << comeca << " " << termina << "\n";
    } else {
      cout << "-1\n";
    }
  }
  return 0;
}
