#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
const int inf = 0x3f3f3f3f;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    int x = 0, y = 0, ans = inf, cnt = 0;
    map<pair<int, int>, int> p;
    string s;
    cin >> n >> s;
    p[make_pair(0, 0)] = 1;
    for (int i = 0; i < n; ++i) {
      if (s[i] == 'L') x -= 1;
      if (s[i] == 'R') x += 1;
      if (s[i] == 'U') y += 1;
      if (s[i] == 'D') y -= 1;
      if (p[make_pair(x, y)] != 0) {
        if (ans >= i + 2 - p[make_pair(x, y)]) {
          ans = i + 2 - p[make_pair(x, y)];
          cnt = i + 2;
        }
      }
      p[make_pair(x, y)] = i + 2;
    }
    if (ans >= inf)
      cout << "-1\n";
    else
      cout << cnt - ans << ' ' << cnt - 1 << endl;
  }
  return 0;
}
