#include <bits/stdc++.h>
#pragma optize("-02")
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string path;
    cin >> path;
    map<pair<int, int>, int> mp;
    int x = 0, y = 0;
    mp[{0, 0}] = 0;
    int l = -1, r = n + 1;
    for (int i = 0; i < n; i++) {
      if (path[i] == 'L') {
        x--;
      }
      if (path[i] == 'R') {
        x++;
      }
      if (path[i] == 'U') {
        y++;
      }
      if (path[i] == 'D') {
        y--;
      }
      if (mp.find({x, y}) == mp.end()) {
        mp[{x, y}] = i + 1;
      } else {
        if (r - l + 1 > (i + 1 - mp[{x, y}] + 1)) {
          l = mp[{x, y}] + 1;
          r = i + 1;
        }
        mp[{x, y}] = i + 1;
      }
    }
    if (l == -1 && r == n + 1) {
      cout << "-1\n";
    } else {
      cout << l << " " << r << "\n";
    }
  }
}
