#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    long long int x = 0, y = 0;
    vector<pair<long long int, long long int>> b;
    b.push_back(make_pair(INT_MIN, INT_MIN));
    b.push_back(make_pair(0, 0));
    for (long long int i = 0; s[i]; i++) {
      if (s[i] == 'L')
        x -= 1;
      else if (s[i] == 'R')
        x += 1;
      else if (s[i] == 'U')
        y += 1;
      else
        y -= 1;
      b.push_back(make_pair(x, y));
    }
    map<pair<long long int, long long int>, long long int> a;
    long long int ml = INT_MAX, p = -1, q = -1, ln;
    n += 2;
    for (long long int i = 0; i < n; i++) {
      long long int temp = a[b[i]];
      if (temp) {
        long long int ln = i - temp;
        if (ln < ml) {
          ml = ln;
          p = temp;
          q = i;
        }
        a[b[i]] = i;
      } else
        a[b[i]] = i;
      if (ml == 2) break;
    }
    if (ml == INT_MAX)
      cout << "-1\n";
    else
      cout << p << " " << q - 1 << "\n";
  }
}
