#include <bits/stdc++.h>
using namespace std;
long long gcd(long long a, long long b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}
vector<pair<int, int> > v;
int main() {
  int t;
  cin >> t;
  while (t--) {
    int yy;
    cin >> yy;
    string s;
    cin >> s;
    int x = 0, y = 0;
    int n = s.length();
    map<pair<int, int>, vector<int> > mp;
    mp[{0, 0}].push_back(0);
    int a = 0, b = 0;
    for (int i = 0; i < n; i += 1) {
      if (s[i] == 'L') {
        a--;
      } else if (s[i] == 'R') {
        a++;
      } else if (s[i] == 'U') {
        b++;
      } else {
        b--;
      }
      mp[{a, b}].push_back(i + 1);
    }
    int ans = n, l = 1;
    bool ok = false;
    for (auto it = mp.begin(); it != mp.end(); it++) {
      for (int i = 1; i < (it->second).size(); i++) {
        ok = true;
        int temp = (it->second)[i] - (it->second)[i - 1];
        if (ans > temp) {
          ans = temp;
          l = 1 + (it->second)[i - 1];
        }
      }
    }
    if (!ok)
      cout << "-1\n";
    else
      cout << l << " " << l + ans - 1 << endl;
  }
}
