#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  cout << setprecision(32);
  int t;
  cin >> t;
  while (t--) {
    int n;
    string str;
    cin >> n >> str;
    int x = 0, y = 0;
    int minlen = n + 5, l = -1, r = -1;
    map<pair<int, int>, int> arr;
    arr[{0, 0}] = -1;
    for (int i = 0; i < n; i++) {
      if (str[i] == 'L') x++;
      if (str[i] == 'R') x--;
      if (str[i] == 'U') y++;
      if (str[i] == 'D') y--;
      if (arr.find({x, y}) != arr.end()) {
        int len = i - arr[{x, y}];
        if (len < minlen) {
          minlen = len;
          l = arr[{x, y}] + 1, r = i;
        }
      }
      arr[{x, y}] = i;
    }
    if (l != -1)
      cout << l + 1 << " " << r + 1 << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
