#include <bits/stdc++.h>
using namespace std;
const long long N = 2e5 + 10;
char s[N];
map<long long, long long> cnt;
signed main() {
  long long t;
  cin >> t;
  while (t--) {
    cnt.clear();
    long long n, sum = 0, ans = 0x3f3f3f3f;
    cin >> n >> s + 1;
    long long one, two;
    cnt[0] = 0;
    for (long long i = 1; i <= n; i++) {
      if (s[i] == 'L') sum--;
      if (s[i] == 'R') sum++;
      if (s[i] == 'U') sum += 0x3f3f3f3f;
      if (s[i] == 'D') sum -= 0x3f3f3f3f;
      if (cnt.count(sum))
        if (ans > i - cnt[sum] + 1)
          one = cnt[sum] + 1, two = i, ans = i - cnt[sum] + 1;
      cnt[sum] = i;
    }
    if (ans == 0x3f3f3f3f)
      cout << -1 << '\n';
    else
      cout << one << " " << two << '\n';
  }
  return 0;
}
