#include <bits/stdc++.h>
#pragma GCC optimize("Ofast,fast-math,unroll-loops")
using namespace std;
const int maxn = 2e5 + 50;
inline char nc() {
  static char buf[100000], *p1 = buf, *p2 = buf;
  return p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2)
             ? EOF
             : *p1++;
}
inline int read() {
  char ch = nc();
  int sum = 0;
  while (!(ch >= '0' && ch <= '9')) ch = nc();
  while (ch >= '0' && ch <= '9') sum = sum * 10 + ch - 48, ch = nc();
  return sum;
}
int t, n;
string str;
int sum1[maxn], sum2[maxn];
map<pair<int, int>, int> mp;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n >> str;
    str = "  " + str;
    n++;
    for (int i = 1; i <= n; i++)
      sum1[i] = sum1[i - 1] + (str[i] == 'L') - (str[i] == 'R'),
      sum2[i] = sum2[i - 1] + (str[i] == 'U') - (str[i] == 'D');
    int ans = 0x3f3f3f3f, l = 0, r = 0;
    mp.clear();
    for (int i = 1; i <= n; i++) {
      if (mp[make_pair(sum1[i], sum2[i])] != 0) {
        int tmp = mp[make_pair(sum1[i], sum2[i])];
        if (i - tmp < ans) ans = i - tmp, l = tmp + 1, r = i;
      }
      mp[make_pair(sum1[i], sum2[i])] = i;
    }
    if (ans == 0x3f3f3f3f)
      printf("-1\n");
    else
      printf("%d %d\n", l - 1, r - 1);
  }
  return 0;
}
