#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<int, int>, int> mp;
    int prefix_sum1 = 0, prefix_sum2 = 0;
    int min_length = INT_MAX;
    int st = -1;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'L') {
        prefix_sum1--;
      } else if (s[i] == 'R') {
        prefix_sum1++;
      } else if (s[i] == 'U') {
        prefix_sum2++;
      } else {
        prefix_sum2--;
      }
      if (prefix_sum2 == 0 && prefix_sum1 == 0) {
        if (min_length > i + 1) {
          min_length = i + 1;
          st = 0;
        }
      }
      pair<int, int> p = make_pair(prefix_sum1, prefix_sum2);
      auto it = mp.find(p);
      if (it != mp.end()) {
        if (min_length > i - it->second) {
          min_length = i - it->second;
          st = it->second + 1;
        }
        it->second = i;
      } else {
        mp[p] = i;
      }
    }
    if (st == -1) {
      cout << -1 << endl;
    } else {
      cout << st + 1 << ' ' << min_length + st << endl;
    }
  }
}
