#include <bits/stdc++.h>
using namespace std;
int main() {
  long long t;
  cin >> t;
  for (int i = 0; i < t; i++) {
    map<pair<long long, long long>, long long> m;
    m[make_pair(0, 0)] = 0;
    string s;
    long long n;
    cin >> n >> s;
    long long x = 0, y = 0, min1 = 1e9 + 7, cnt, cnt1;
    s = "1" + s;
    for (int j = 1; j < s.size(); j++) {
      if (s[j] == 'R')
        x++;
      else if (s[j] == 'L')
        x--;
      else if (s[j] == 'U')
        y++;
      else if (s[j] == 'D')
        y--;
      if (m.find(make_pair(x, y)) != m.end() && j - m[make_pair(x, y)] < min1) {
        min1 = j - m[make_pair(x, y)];
        cnt = m[make_pair(x, y)] + 1;
        cnt1 = j;
      }
      m[make_pair(x, y)] = j;
    }
    if (min1 == 1e9 + 7)
      cout << -1 << endl;
    else
      cout << cnt << ' ' << cnt1 << endl;
  }
  return 0;
}
