#include <bits/stdc++.h>
using namespace std;
int t, n;
char str[200005];
pair<int, int> pref[200005];
map<pair<int, int>, int> _map;
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> t;
  while (t--) {
    cin >> n;
    cin >> str + 1;
    int dr = 0, dc = 0;
    for (int i = 1; i <= n; i++) {
      char ch = str[i];
      if (ch == 'R') {
        dr++;
      } else if (ch == 'L') {
        dr--;
      } else if (ch == 'U') {
        dc++;
      } else {
        dc--;
      }
      pref[i].first = dr;
      pref[i].second = dc;
    }
    int r = n, l = -1;
    for (int i = 0; i <= n; i++) {
      int f = pref[i].first;
      int s = pref[i].second;
      if (_map[{f, s}]) {
        if (i - _map[{f, s}] < r - l) {
          l = _map[{f, s}];
          r = i;
        }
      }
      _map[{f, s}] = i + 1;
    }
    if (l != -1) {
      cout << l << " " << r << endl;
    } else {
      cout << l << endl;
    }
    _map.clear();
  }
  return 0;
}
