#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    s = '#' + s;
    n = s.length();
    map<pair<long long int, long long int>, long long int> check;
    vector<pair<long long int, long long int>> ans;
    long long int x = 0, y = 0;
    check[make_pair(x, y)] = 1;
    for (long long int(i) = (1); (i) < (n); (i)++) {
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
      if (s[i] == 'U') y++;
      if (s[i] == 'D') y--;
      if (check[make_pair(x, y)] == 0) {
        check[make_pair(x, y)] = i + 1;
        continue;
      }
      if (check[make_pair(x, y)] > 0) {
        ans.push_back(
            make_pair(i - check[make_pair(x, y)], check[make_pair(x, y)]));
        check[make_pair(x, y)] = i + 1;
      }
    }
    if (ans.size() == 0) {
      cout << -1 << "\n";
    } else {
      sort((ans).begin(), (ans).end());
      cout << ans[0].second << " " << ans[0].second + ans[0].first << "\n";
    }
  }
  return 0;
}
