#include <bits/stdc++.h>
using namespace std;
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
  if (0) return;
  cout << name << " : " << arg1 << '\n';
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
  if (0) return;
  const char* comma = strchr(names + 1, ',');
  cout.write(names, comma - names) << " : " << arg1 << " | ";
  __f(comma + 1, args...);
}
inline void INP();
const long long N = 3e6 + 7, M = 1000000007, inf = INT_MAX;
const long long INF = LLONG_MAX;
long long n, Q;
long long arr[N + 2];
void solve() {
  string str;
  cin >> n >> str;
  long long k = 1e6;
  map<char, long long> gt;
  gt['L'] = 1, gt['R'] = -1, gt['U'] = k, gt['D'] = -k;
  map<long long, long long> mp;
  mp[0] = -1;
  long long ans = inf, id = -1, sum = 0;
  for (long long i = 0; i < (long long)n; i++) {
    sum += gt[str[i]];
    if (mp.count(sum)) {
      long long l = mp[sum] + 1;
      if (i - l + 1 < ans) {
        ans = i - l + 1;
        id = l;
      }
    }
    mp[sum] = i;
  }
  if (id != -1) {
    cout << id + 1 << " " << id + ans << '\n';
  } else
    cout << -1 << '\n';
}
int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  INP();
  long long test = 1;
  cin >> test;
  while (test--) solve();
}
inline void INP() {}
