#include <bits/stdc++.h>
using namespace std;
struct node {
  long long int x;
  long long int y;
  node(long long int x, long long int y) { x = x, y = y; }
};
int main() {
  long long int t;
  cin >> t;
  while (t--) {
    long long int n;
    cin >> n;
    string s;
    cin >> s;
    long long int x = 0, y = 0, mini = INT_MAX, minix = -1, miniy = -1;
    map<pair<long long int, long long int>, long long int> mp;
    mp[{0, 0}] = 0;
    for (long long int i = 0; i < n; i++) {
      if (s[i] == 'L') x--;
      if (s[i] == 'R') x++;
      if (s[i] == 'U') y++;
      if (s[i] == 'D') y--;
      if ((x == 0) && (y == 0)) {
        if ((i + 1) < mini) {
          mini = i + 1;
          minix = 0;
          miniy = i;
        }
      }
      auto p = make_pair(x, y);
      if (mp.find(p) != mp.end()) {
        if (mini > (i - mp[p] + 1)) {
          mini = i - mp[p] + 1;
          minix = mp[p] + 1;
          miniy = i;
        }
      }
      mp[p] = i;
    }
    if (minix == -1)
      cout << -1 << endl;
    else
      cout << minix + 1 << " " << miniy + 1 << endl;
  }
}
