#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  long long t;
  cin >> t;
  while (t--) {
    long long n;
    cin >> n;
    string str;
    cin >> str;
    map<pair<long long, long long>, long long> mp;
    long long x = 0, y = 0, ctr = 0, ans = 10000000000, fs, sc;
    mp[{0, 0}] = 0;
    for (auto it : str) {
      ctr++;
      if (it == 'L') {
        x--;
      } else if (it == 'R') {
        x++;
      } else if (it == 'U') {
        y++;
      } else {
        y--;
      }
      if (mp.find({x, y}) == mp.end()) {
        mp[{x, y}] = ctr;
      } else {
        if (ans > (ctr - mp[{x, y}])) {
          ans = (ctr - mp[{x, y}]);
          fs = mp[{x, y}] + 1;
          sc = ctr;
          mp[{x, y}] = ctr;
        } else {
          mp[{x, y}] = ctr;
        }
      }
    }
    if (ans == 10000000000) {
      cout << -1 << "\n";
    } else {
      cout << fs << " " << sc << "\n";
    }
  }
}
