#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;
void dir(char& smb, int& x, int& y) {
  if (smb == 'L')
    x--;
  else if (smb == 'R')
    x++;
  else if (smb == 'U')
    y++;
  else
    y--;
}
void solve() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  map<pair<int, int>, int> mpp;
  int x = 0, y = 0;
  mpp[make_pair(0, 0)] = 0;
  int mn = n + 5, l = -1, r = n + 1;
  for (int i = 1; i < n + 1; i++) {
    char smb = s[i - 1];
    dir(smb, x, y);
    auto it = mpp.find(make_pair(x, y));
    if (it != mpp.end()) {
      pair<pair<int, int>, int> p = *it;
      int ind = p.second;
      if (i - ind - 1 < mn) {
        mn = i - ind - 1;
        l = ind;
        r = i - 1;
      }
    }
    mpp[make_pair(x, y)] = i;
  }
  if (l == -1)
    cout << "-1\n";
  else
    cout << l + 1 << " " << r + 1 << "\n";
}
int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int tc;
  cin >> tc;
  while (tc--) solve();
  return 0;
}
