#include <bits/stdc++.h>
using namespace std;
void solve() {
  long long n;
  cin >> n;
  map<long long, vector<long long>> m;
  m[0].push_back(0);
  long long now = 0;
  for (long long i = 0; i < n; ++i) {
    char x;
    cin >> x;
    if (x == 'L') {
      now -= 1;
    } else if (x == 'R') {
      now += 1;
    } else if (x == 'U') {
      now += (long long)1e9;
    } else if (x == 'D') {
      now -= (long long)1e9;
    }
    m[now].push_back(i + 1);
  }
  pair<long long, long long> ans = {0, INT_MAX};
  for (auto i : m) {
    for (long long j = 0; j < i.second.size() - 1; ++j) {
      if (i.second[j + 1] - i.second[j] < ans.second - ans.first) {
        ans = {i.second[j] + 1, i.second[j + 1]};
      }
    }
  }
  if (ans.second == INT_MAX) {
    cout << -1 << endl;
  } else {
    cout << ans.first << ' ' << ans.second << endl;
  }
}
int main() {
  long long t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
