#include <bits/stdc++.h>
using namespace std;
int t, n;
string s;
int main(void) {
  cin >> t;
  while (t--) {
    map<pair<int, int>, int> m;
    int start = 0, end = 2147483647, x = 0, y = 0;
    cin >> n >> s;
    s.insert(s.begin(), '0');
    m.insert({make_pair(0, 0), 0});
    for (int i = 1; i < s.size(); i++) {
      if (s[i] == 'L')
        x -= 1;
      else if (s[i] == 'R')
        x += 1;
      else if (s[i] == 'U')
        y += 1;
      else
        y -= 1;
      pair<int, int> p = make_pair(x, y);
      if (m.find(p) == m.end()) {
        m.insert({p, i});
      } else {
        if (i - m[p] < end - start) {
          start = m[p] + 1;
          end = i;
        }
        m[p] = i;
      }
    }
    if (end == 2147483647)
      cout << "-1\n";
    else
      cout << start << " " << end << endl;
  }
}
