#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  for (cin >> t; t--;) {
    long long n;
    cin >> n;
    string s;
    cin >> s;
    long long i, x = 0, y = 0;
    char ch;
    map<pair<long long, long long>, long long> mp;
    mp[{0, 0}] = 0;
    pair<long long, long long> ans = {-1, n + 1};
    for (i = 1; i < n + 1; i++) {
      ch = s[i - 1];
      if (ch == 'L')
        x--;
      else if (ch == 'R')
        x++;
      else if (ch == 'U')
        y++;
      else if (ch == 'D')
        y--;
      map<pair<long long, long long>, long long>::iterator it = mp.find({x, y});
      if (it != mp.end()) {
        if (i - it->second < ans.second - ans.first) ans = {it->second + 1, i};
        it->second = i;
      } else
        mp[{x, y}] = i;
    }
    cout << ans.first << " ";
    if (ans.first != -1) cout << ans.second;
    cout << '\n';
  }
  return 0;
}
