#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    vector<pair<int, int> > opt;
    int n;
    cin >> n;
    map<pair<int, int>, int> stage;
    pair<int, int> current = pair<int, int>(0, 0);
    stage[current] = 0;
    for (int i = 1; i <= n; i++) {
      char c;
      cin >> c;
      if (c == 'L') {
        current.first++;
      } else if (c == 'R') {
        current.first--;
      } else if (c == 'U') {
        current.second++;
      } else {
        current.second--;
      }
      if (stage.find(current) != stage.end())
        opt.push_back({stage[current] + 1, i});
      stage[current] = i;
    }
    long long _min = INT_MAX;
    pair<int, int> ans;
    for (pair<int, int> p : opt) {
      int diff = abs(p.first - p.second);
      if (diff < _min) {
        _min = diff;
        ans = p;
      }
    }
    if (opt.size())
      cout << min(ans.first, ans.second) << " " << max(ans.first, ans.second)
           << endl;
    else
      cout << -1 << endl;
  }
  return 0;
}
