#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int t, i, n, index, f, left, right, start, end, ans, res;
  string s;
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> s;
    f = 0;
    for (i = 0; i < n - 1; i++) {
      if (s[i] == 'L' && s[i + 1] == 'R') {
        f = 1;
        index = i;
        break;
      }
      if (s[i] == 'R' && s[i + 1] == 'L') {
        f = 1;
        index = i;
        break;
      }
      if (s[i] == 'U' && s[i + 1] == 'D') {
        f = 1;
        index = i;
        break;
      }
      if (s[i] == 'D' && s[i + 1] == 'U') {
        f = 1;
        index = i;
        break;
      }
    }
    if (f == 1) {
      cout << index + 1 << " " << index + 2 << "\n";
    } else {
      map<pair<long long int, long long int>, vector<long long int>> mp;
      mp[{0, 0}].push_back(0);
      start = 0;
      end = 0;
      for (i = 0; i < n; i++) {
        if (s[i] == 'L') {
          --start;
          mp[{start, end}].push_back(i + 1);
        }
        if (s[i] == 'R') {
          ++start;
          mp[{start, end}].push_back(i + 1);
        }
        if (s[i] == 'U') {
          end++;
          mp[{start, end}].push_back(i + 1);
        }
        if (s[i] == 'D') {
          end--;
          mp[{start, end}].push_back(i + 1);
        }
      }
      res = LLONG_MAX;
      for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
        if (itr->second.size() > 1) {
          for (i = 0; i < itr->second.size() - 1; i++) {
            ans = abs(itr->second[i] - itr->second[i + 1]);
            if (ans < res) {
              res = ans;
              left = itr->second[i];
              right = itr->second[i + 1];
            }
          }
        }
      }
      if (res == LLONG_MAX) {
        cout << -1 << "\n";
      } else {
        cout << left + 1 << " " << right << "\n";
      }
    }
  }
  return 0;
}
