#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  long long x, y, n, m, t, q, a, b, count = 0, a1, a2;
  cin >> t;
  string s;
  for (q = 0; q < t; q++) {
    cin >> n;
    cin >> s;
    map<pair<long long, long long>, long long> mp;
    mp[{0, 0}] = -1;
    long long ans = 1e13, a = b = 0;
    for (x = 0; x < n; x++) {
      if (s[x] == 'L')
        a++;
      else if (s[x] == 'R')
        a--;
      else if (s[x] == 'U')
        b++;
      else if (s[x] == 'D')
        b--;
      if (mp.find({a, b}) != mp.end()) {
        if (x - mp[{a, b}] < ans) {
          ans = x - mp[{a, b}];
          a1 = mp[{a, b}];
          a2 = x;
        }
      }
      mp[{a, b}] = x;
    }
    if (ans == 1e13)
      cout << "-1" << endl;
    else
      cout << a1 + 2 << " " << a2 + 1 << endl;
  }
}
