#include <bits/stdc++.h>
using namespace std;
string to_string(string s) { return '"' + s + '"'; }
string to_string(char s) { return string(1, s); }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A>
string to_string(A);
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool f = 1;
  string r = "{";
  for (const auto& x : v) {
    if (!f) r += ", ";
    f = 0;
    r += to_string(x);
  }
  return r + "}";
}
void debug_out() { cerr << '\n'; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
void printallSubarrays(long long arr[], long long n) {
  long long y = 1000000, x = 0;
  map<long long, long long> sumset;
  sumset[0] = -1;
  long long sum = 0;
  for (long long i = 0; i < n; i++) {
    sum += arr[i];
    if (sum == 0 || sumset[sum] > 0) {
      if (y - x >= (i - sumset[sum])) {
        y = i, x = sumset[sum] + 1;
      }
    }
    if (sum != 0 && sum == arr[0] && i != 0) {
      if (y - x >= (i - sumset[sum])) {
        y = i, x = sumset[sum] + 1;
      }
    }
    sumset[sum] = i;
  }
  if (y - x != 1000000)
    cout << x + 1 << " " << y + 1 << '\n';
  else
    cout << -1 << '\n';
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int t;
  cin >> t;
  while (t--) {
    string s;
    long long n;
    cin >> n;
    cin >> s;
    long long arr[n];
    for (long long i = 0; i < n; i++) {
      if (s[i] == 'L') arr[i] = -1;
      if (s[i] == 'R') arr[i] = 1;
      if (s[i] == 'U') arr[i] = 300000;
      if (s[i] == 'D') arr[i] = -300000;
    }
    printallSubarrays(arr, n);
    cerr << "["
         << "s"
         << "]:",
        debug_out(s);
  }
  return 0;
}
