#include <bits/stdc++.h>
using namespace std;
long long fast_pow(long long x, long long y, long long p);
void solve() {
  long long n;
  cin >> n;
  string s;
  cin >> s;
  map<pair<long long, long long>, long long> mp;
  mp[{0, 0}] = 0;
  long long x = 0, y = 0;
  long long ansx = 0, ansy = 0;
  long long diff = INT_MAX;
  for (long long i = 0; i < n; i++) {
    if (s[i] == 'L') x--;
    if (s[i] == 'R') x++;
    if (s[i] == 'U') y++;
    if (s[i] == 'D') y--;
    if (mp.find({x, y}) != mp.end()) {
      long long temp = (i - mp[{x, y}] + 1);
      if (temp < diff) {
        diff = temp;
        ansx = mp[{x, y}] + 1;
        ansy = i + 1;
      }
    }
    mp[{x, y}] = i + 1;
  }
  if (diff == INT_MAX)
    cout << -1 << "\n";
  else {
    cout << ansx << " " << ansy << "\n";
  }
}
int32_t main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  long long test = 1;
  cin >> test;
  while (test--) {
    solve();
  }
  return 0;
}
long long fast_pow(long long x, long long y, long long p) {
  long long res = 1;
  x = x % p;
  while (y > 0) {
    if (y & 1) res = (res * x) % p;
    y = y >> 1;
    x = (x * x) % p;
  }
  return res;
}
