#include <bits/stdc++.h>
using namespace std;
const long long losn = 1e6 + 5;
const long long maxn = 1e5 + 5;
const long long minn = 1e3 + 5;
const long long tiny = 1e2 + 5;
const long long inf = 1e9;
const long long mod = 1e9 + 7;
const long long hmod = 4698571;
long long n;
char c[maxn * 2];
map<pair<long long, long long>, long long> mp;
int main() {
  long long t;
  cin >> t;
  while (t--) {
    cin >> n;
    long long ansl = 1, ansr = n;
    scanf(" %s", c + 1);
    long long anslen = inf;
    mp.clear();
    long long x = 0, y = 0;
    pair<long long, long long> ps(x, y);
    mp[ps] = 0;
    for (long long i = 1; i <= n; i++) {
      if (c[i] == 'L') {
        x--;
      } else if (c[i] == 'R') {
        x++;
      } else if (c[i] == 'D') {
        y--;
      } else if (c[i] == 'U') {
        y++;
      }
      pair<long long, long long> p(x, y);
      if (mp.count(p)) {
        long long len = i - mp[p];
        if (len < anslen) {
          anslen = len;
          ansl = mp[p] + 1;
          ansr = i;
        }
      }
      mp[p] = i;
    }
    if (anslen != inf) {
      cout << ansl << " " << ansr << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
