#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;
const int N = 2e5 + 10;
int q;
int n;
char s[N];
int s1[N], s2[N];
map<pair<int, int>, int> t;
int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cin >> q;
  while (q--) {
    cin >> n;
    cin >> s + 1;
    t.clear();
    t[make_pair(0, 0)] = 0;
    int minn = INF, l, r;
    for (int i = 1; i <= n; ++i) {
      s1[i] = s1[i - 1];
      s2[i] = s2[i - 1];
      if (s[i] == 'L') s1[i]--;
      if (s[i] == 'R') s1[i]++;
      if (s[i] == 'D') s2[i]--;
      if (s[i] == 'U') s2[i]++;
      pair<int, int> tmp = make_pair(s1[i], s2[i]);
      if (t.find(tmp) != t.end())
        if (i - t[tmp] < minn) {
          minn = i - t[tmp];
          l = t[tmp] + 1;
          r = i;
        }
      t[tmp] = i;
    }
    if (minn == INF)
      cout << -1 << endl;
    else
      cout << l << " " << r << endl;
  }
  return 0;
}
