#include <bits/stdc++.h>
using namespace std;
const int INF = 1000 * 1000 * 1000;
const int maxn = 2e5;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<int, int>, int> m;
    m[{0, 0}] = 0;
    int x = 0, y = 0;
    int min = INF, ansx = 0, ansy = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'U')
        y++;
      else if (s[i] == 'D')
        y--;
      else if (s[i] == 'R')
        x++;
      else
        x--;
      pair<int, int> t = make_pair(x, y);
      if (m.count(t)) {
        if (i - m[t] < min) {
          min = i - m[t];
          ansx = m[t] + 1;
          ansy = i + 1;
        }
      }
      m[t] = i + 1;
    }
    if (min == INF) {
      cout << -1 << endl;
    } else {
      cout << ansx << ' ' << ansy << endl;
    }
  }
  return 0;
}
