#include <bits/stdc++.h>
using namespace std;
const long long N = 100005;
const long long M = 1000000007;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long t;
  cin >> t;
  for (long long w = 0; w < t; w++) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    set<vector<long long> > v;
    vector<long long> vf;
    vf.push_back(0);
    vf.push_back(0);
    vf.push_back(0);
    v.insert(vf);
    long long x = 0, y = 0;
    for (long long i = 0; i < n; i++) {
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
      if (s[i] == 'U') y++;
      if (s[i] == 'D') y--;
      vector<long long> vd;
      vd.push_back(x);
      vd.push_back(y);
      vd.push_back(i + 1);
      v.insert(vd);
    }
    long long flag = 1;
    long long ind = M;
    long long ind2;
    long long ind3;
    set<vector<long long> >::iterator it = v.begin();
    set<vector<long long> >::iterator it2 = v.begin();
    for (long long i = 0; i < n; i++) {
      it2++;
      if ((*it)[0] == (*(it2))[0] && (*it)[1] == (*(it2))[1]) {
        flag = 0;
        if (ind > ((*(it2))[2] - (*(it))[2])) {
          ind = ((*(it2))[2] - (*(it))[2]);
          ind2 = (*it)[2] + 1;
          ind3 = (*it2)[2];
        }
      }
      it++;
    }
    if (flag == 1)
      cout << -1 << endl;
    else
      cout << ind2 << " " << ind3 << endl;
  }
  return 0;
}
