#include <bits/stdc++.h>
using namespace std;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x, y;
    x = 0, y = 0;
    vector<pair<int, int>> points;
    map<pair<int, int>, int> mp;
    int left, right;
    left = -1;
    right = n;
    mp[{0, 0}] = 0;
    for (int i = 0; i < n; i++) {
      if (s[i] == 'L') {
        x = x - 1;
      } else if (s[i] == 'U') {
        y = y + 1;
      } else if (s[i] == 'R') {
        x = x + 1;
      } else if (s[i] == 'D') {
        y = y - 1;
      }
      if (mp.find({x, y}) != mp.end()) {
        if (abs(i - mp[{x, y}] + 1) < (abs(right - left + 1))) {
          left = mp[{x, y}] + 1;
          right = i + 1;
        }
      }
      mp[{x, y}] = i + 1;
    }
    if (left != -1) {
      cout << left << " " << right << endl;
      continue;
    } else {
      cout << "-1" << endl;
      continue;
    }
  }
  return 0;
}
