#include <bits/stdc++.h>
using namespace std;
unordered_map<long long int, unordered_map<long long int, long long int> > smap;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  ;
  long long int t, n;
  cin >> t;
  string s;
  while (t--) {
    cin >> n;
    cin >> s;
    long long int x = 0, y = 0;
    long long int stopx = 0, stopy = 0;
    long long int ops = 0, ans = 1e18, left, right;
    smap[0][0] = 0;
    for (unsigned long long i = 0; i < n; i++) {
      ops++;
      if (s[i] == 'U') {
        stopy += 1;
      }
      if (s[i] == 'D') {
        stopy -= 1;
      }
      if (s[i] == 'R') {
        stopx += 1;
      }
      if (s[i] == 'L') {
        stopx -= 1;
      }
      if (smap[stopx][stopy] > 0 || (stopx == 0 && stopy == 0)) {
        long long int diff = ops - smap[stopx][stopy];
        if (diff < ans) {
          ans = diff;
          left = smap[stopx][stopy] + 1;
          right = ops;
        }
      }
      smap[stopx][stopy] = ops;
    }
    if (stopx == 0 && stopy == 0) {
      if (ans < n)
        cout << left << " " << right << endl;
      else
        cout << 1 << " " << n << endl;
    } else {
      if (ans == 1e18)
        cout << -1 << endl;
      else
        cout << left << " " << right << endl;
    }
    smap.clear();
  }
}
