#include <bits/stdc++.h>
using namespace std;
long long mod = 1e9 + 7;
int expo(int base, int exponent) {
  int ans = 1;
  while (exponent != 0) {
    if (exponent & 1) ans = (1LL * ans * base) % mod;
    base = (1LL * base * base) % mod;
    exponent >>= 1;
  }
  return ans % mod;
}
long long dig(long long s) {
  long long ans = 0;
  while (s >= 10) {
    ans++;
    s /= 10;
  }
  return ans;
}
int main() {
  long long tests = 1;
  cin >> tests;
  while (tests--) {
    long long n, i, left = -1, right = -1, ans = INT_MAX, x = 0, y = 0;
    cin >> n;
    string s;
    cin >> s;
    map<pair<long long, long long>, long long> mp;
    mp[{0, 0}] = 0;
    for (i = 1; i <= n; i++) {
      if (s[i - 1] == 'U')
        y++;
      else if (s[i - 1] == 'D')
        y--;
      else if (s[i - 1] == 'L')
        x--;
      else
        x++;
      pair<long long, long long> p = {x, y};
      if (mp.find(p) != mp.end()) {
        if (ans > i - mp[p]) {
          ans = i - mp[p];
          left = mp[p] + 1;
          right = i;
        }
      }
      mp[p] = i;
    }
    if (left == -1)
      cout << -1 << "\n";
    else
      cout << left << " " << right << "\n";
  }
  return 0;
}
