#include <bits/stdc++.h>
using namespace std;
const long long logN = 20;
const long long M = 1000000007;
const long long INF = 1e12;
const long long N = 100005;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long no;
  cin >> no;
  while (no--) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<long long, long long>, long long> m;
    m[{0, 0}] = -1;
    long long ans = M;
    long long x = 0, y = 0;
    long long st = 0, en = 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--;
      }
      if (m.count({x, y}) != 0) {
        long long p = i - m[{x, y}];
        if (p < ans) {
          ans = p;
          st = m[{x, y}] + 1;
          en = i;
        }
      }
      m[{x, y}] = i;
    }
    if (ans == M) {
      cout << -1 << "\n";
      continue;
    }
    cout << st + 1 << " " << en + 1 << "\n";
  }
  return 0;
}
