#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
void init_io() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
void solve() {
  ll n, l, r, dis = 100000000000000;
  map<P, ll> mp;
  P pt(0, 0);
  string s;
  cin >> n >> s;
  mp[pt] = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'L') pt.first--;
    if (s[i] == 'R') pt.first++;
    if (s[i] == 'D') pt.second--;
    if (s[i] == 'U') pt.second++;
    auto itr = mp.find(pt);
    if (itr != mp.end()) {
      if (i - itr->second + 1 < dis) {
        dis = i - itr->second + 1;
        l = itr->second;
        r = i;
      }
    }
    mp[pt] = i + 1;
  }
  if (dis == 100000000000000) {
    cout << "-1\n";
  } else {
    cout << l + 1 << " " << r + 1 << endl;
  }
}
signed main() {
  init_io();
  ll t;
  cin >> t;
  while (t != 0) {
    solve();
    t--;
  }
}
