#include <bits/stdc++.h>
using namespace std;
int difx[200005], dify[200005], ans;
int t, n, l, r;
char a[200005];
map<pair<int, int>, int> mp;
int main() {
  cin >> t;
  map<pair<int, int>, int>::iterator iter;
  while (t--) {
    scanf("%d", &n);
    ans = 0x3f3f3f3f;
    mp.clear();
    mp[make_pair(0, 0)] = 0;
    scanf("%s", a + 1);
    for (int i = 1; i <= n; i++) {
      difx[i] = difx[i - 1];
      dify[i] = dify[i - 1];
      if (a[i] == 'L')
        difx[i]++;
      else if (a[i] == 'R')
        difx[i]--;
      else if (a[i] == 'U')
        dify[i]++;
      else
        dify[i]--;
      iter = mp.find(make_pair(difx[i], dify[i]));
      if (iter != mp.end()) {
        int u = iter->second;
        if (ans > i - u) ans = i - u, l = u + 1, r = i;
      }
      mp[make_pair(difx[i], dify[i])] = i;
    }
    if (ans != 0x3f3f3f3f)
      printf("%d %d\n", l, r);
    else
      printf("-1\n");
  }
  return 0;
}
