#include <bits/stdc++.h>
using namespace ::std;
using ll = long long;
using pii = pair<int, int>;
const int inf = INT_MAX, mod = 1e9 + 7;
void print(vector<int>& vec) {
  for (int i = 0; i < vec.size(); i++) {
    cout << vec[i] << ' ';
  }
  cout << '\n';
}
signed main() {
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string str;
    cin >> str;
    int l = -1, r = n;
    map<pii, int> vis;
    pii cur = {0, 0};
    vis[cur] = 0;
    for (int i = 0; i < n; i++) {
      if (str[i] == 'L') --cur.first;
      if (str[i] == 'R') ++cur.first;
      if (str[i] == 'D') --cur.second;
      if (str[i] == 'U') ++cur.second;
      if (vis.count(cur) && i - vis[cur] + 1 < r - l + 1) l = vis[cur], r = i;
      vis[cur] = i + 1;
    }
    if (l == -1)
      cout << -1;
    else
      cout << l + 1 << ' ' << r + 1;
    cout << '\n';
  }
  return 0;
}
