#include <bits/stdc++.h>
using namespace std;
const int M = 1e9 + 7;
void solve() {
  int n;
  string s;
  cin >> n >> s;
  map<pair<long long, long long>, long long> m;
  m[{0, 0}] = -1;
  pair<long long, long long> p = {0, 0};
  long long ans = 1e9;
  int en = 0;
  for (int i = 0; i < n; ++i) {
    if (s[i] == 'U') {
      ++p.second;
    } else if (s[i] == 'D') {
      --p.second;
    } else if (s[i] == 'L') {
      --p.first;
    } else {
      ++p.first;
    }
    if (m.count(p)) {
      if (i - m[p] < ans) {
        ans = i - m[p];
        en = i;
      }
    }
    m[p] = i;
  }
  if (ans == 1e9) {
    cout << -1 << "\n";
    return;
  }
  cout << (en - ans + 1) + 1 << " " << en + 1 << "\n";
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    solve();
  }
  return 0;
}
