#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  ;
  long long int test;
  map<pair<long long int, long long int>, long long int> mapped;
  string s;
  long long int n;
  cin >> test;
  while (test--) {
    cin >> n;
    cin >> s;
    mapped.clear();
    long long int ans = 1e18 + 9, l = -1, r = -1;
    long long int x = 0, y = 0;
    mapped[make_pair(x, y)] = -1;
    for (long long int i = 0; i < n; i++) {
      if (s[i] == 'L') {
        --x;
      } else if (s[i] == 'R') {
        ++x;
      } else if (s[i] == 'D') {
        --y;
      } else {
        ++y;
      }
      if (mapped.find(make_pair(x, y)) != mapped.end()) {
        long long int indx = mapped[make_pair(x, y)];
        if (ans > i - indx) {
          ans = i - indx;
          l = indx + 1;
          r = i;
        }
        mapped[make_pair(x, y)] = i;
      } else {
        mapped[make_pair(x, y)] = i;
      }
    }
    if (l != -1 && r != -1) {
      cout << l + 1 << " " << r + 1 << endl;
    } else {
      cout << -1 << endl;
    }
  }
}
