#include <bits/stdc++.h>
using namespace std;
pair<int, int> temp;
map<pair<int, int>, int> mp;
int n, l, r;
string str;
int main() {
  int num;
  cin >> num;
  while (num--) {
    mp.clear();
    temp;
    temp.first = 0;
    temp.second = 0;
    mp[temp] = 0;
    cin >> n;
    l = -1;
    r = n;
    string str;
    cin >> str;
    for (int i = 0; i < str.size(); i++) {
      if (str[i] == 'L')
        temp.first--;
      else if (str[i] == 'R')
        temp.first++;
      else if (str[i] == 'U')
        temp.second--;
      else
        temp.second++;
      if (mp.count(temp)) {
        if (i + 1 - mp[temp] < r - l) {
          r = i + 1;
          l = mp[temp];
        }
      }
      mp[temp] = i + 1;
    }
    if (l == -1)
      printf("-1\n");
    else
      printf("%d %d\n", l + 1, r);
  }
}
