#include <bits/stdc++.h>
using namespace std;
const long long INF = 1001001001;
const long long LINF = 1001001001001001001ll;
const long long MOD = 1000000007;
const double EPS = 1e-9;
template <typename T>
ostream& operator<<(ostream& s, const vector<T>& v) {
  long long len = v.size();
  for (long long i = 0; i < len; ++i) {
    s << v[i];
    if (i < len - 1) s << ' ';
  }
  return s;
}
template <typename T>
ostream& operator<<(ostream& s, const vector<vector<T>>& vv) {
  long long len = vv.size();
  for (long long i = 0; i < len; ++i) {
    s << vv[i];
    if (i != len - 1) s << '\n';
  }
  return s;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
__attribute__((constructor)) void initial() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
}
map<char, long long> dx = {{'R', 1}, {'L', -1}, {'U', 0}, {'D', 0}};
map<char, long long> dy = {{'R', 0}, {'L', 0}, {'U', 1}, {'D', -1}};
signed main() {
  long long t;
  cin >> t;
  while (t-- > 0) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    pair<long long, long long> now = make_pair(0, 0);
    map<pair<long long, long long>, long long> m;
    m[now] = 0;
    long long mn = INF;
    long long l = -1, r = -1;
    for (long long i = 0; i < (n); ++i) {
      now.first += dx[s[i]];
      now.second += dy[s[i]];
      if (m.find(now) == m.end()) {
        m[now] = i + 1;
      } else {
        if (chmin(mn, i + 1 - m[now])) l = m[now] + 1, r = i + 1;
        m[now] = i + 1;
      }
    }
    if (l == -1)
      cout << -1 << '\n';
    else
      cout << l << ' ' << r << endl;
  }
}
