#include <bits/stdc++.h>
using namespace std;
int32_t main() {
  long long t;
  cin >> t;
  while ((t--)) {
    long long n;
    cin >> n;
    string str;
    cin >> str;
    map<pair<long long, long long>, long long> mp;
    pair<long long, long long> c = {0, 0};
    mp[c] = -1;
    long long max = INT_MAX;
    long long l, r;
    long long left = 0;
    long long right = 0;
    long long len = 0;
    long long leftlen = 0, rightlen = 0;
    for (long long i = 0; i < n; i++) {
      char x = str[i];
      if (x == 'L') {
        c.first++;
        left++;
        right = 0;
        rightlen = 0;
        leftlen++;
      } else if (x == 'R') {
        c.first--;
        left--;
        right = 0;
        rightlen = 0;
        leftlen++;
      } else if (x == 'U') {
        c.second++;
        right++;
        left = 0;
        leftlen = 0;
        rightlen++;
      } else {
        c.second--;
        right--;
        left = 0;
        leftlen = 0;
        rightlen++;
      }
      if (mp.count(c)) {
        long long cur = i - mp[c];
        if (cur < max) {
          l = mp[c] + 2;
          r = i + 1;
          max = cur;
        }
      }
      if (leftlen && !left) {
        if (leftlen < max) {
          max = leftlen;
          l = i - leftlen + 2;
          r = i + 1;
        }
      }
      if (rightlen && !right) {
        if (rightlen < max) {
          max = rightlen;
          l = i - rightlen + 2;
          r = i + 1;
        }
      }
      mp[c] = i;
    }
    if (max == INT_MAX) {
      cout << -1 << endl;
    } else {
      cout << l << " " << r << endl;
    }
  }
}
