#include <bits/stdc++.h>
using namespace std;
namespace IO {
static char buf[1 << 20], *fs, *ft;
inline char gc() {
  if (fs == ft) {
    ft = (fs = buf) + fread(buf, 1, 1 << 20, stdin);
    if (fs == ft) return EOF;
  }
  return *fs++;
}
inline int read() {
  int x = 0, f = 1;
  char s = getchar();
  while (s < '0' || s > '9') {
    if (s == '-') f = -f;
    s = getchar();
  }
  while (s >= '0' && s <= '9') {
    x = x * 10 + s - '0';
    s = getchar();
  }
  return x * f;
}
}  // namespace IO
using IO::read;
map<pair<int, int>, int> pos;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
int p[256];
void move(int n) {
  static char c;
  while ((c = getchar()) != 'U' and c != 'L' and c != 'R' and c != 'D')
    ;
  pos.clear();
  pair<int, int> now = make_pair(dx[p[c]], dy[p[c]]);
  pos[make_pair(0, 0)] = 1, pos[now] = 2;
  int ans = 1 << 30, ansl = 0, ansr = 0;
  for (int i = 2; i <= n; i++) {
    c = getchar();
    int rex = now.first + dx[p[c]], rey = now.second + dy[p[c]];
    pair<int, int> Next = make_pair(rex, rey);
    if (pos[Next]) {
      if (i - pos[Next] + 1 < ans)
        ans = i - pos[Next] + 1, ansl = pos[Next], ansr = i;
    }
    pos[now = Next] = i + 1;
  }
  if (ansl and ansr)
    printf("%d %d\n", ansl, ansr);
  else
    puts("-1");
}
int main() {
  p['U'] = 1, p['D'] = 3;
  p['L'] = 2, p['R'] = 0;
  int T = read();
  while (T--) move(read());
  return 0;
}
