#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e5 + 5;
int t, n;
char s[maxn];
map<pair<int, int>, int> mp;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> t;
  while (t--) {
    mp.clear();
    cin >> n;
    cin >> (s + 1);
    int L, R;
    int ans = 0x3f3f3f3f;
    int x = 0, y = 0;
    mp[pair<int, int>(x, y)] = 0;
    for (int i = 1; i <= n; i++) {
      if (s[i] == 'L')
        x--;
      else if (s[i] == 'R')
        x++;
      else if (s[i] == 'U')
        y++;
      else
        y--;
      pair<int, int> tmp = make_pair(x, y);
      if (mp.count(tmp)) {
        if (ans > i - mp[tmp]) {
          ans = i - mp[tmp];
          L = mp[tmp] + 1;
          R = i;
        }
      }
      mp[tmp] = i;
    }
    if (ans == 0x3f3f3f3f)
      cout << -1 << '\n';
    else
      cout << L << " " << R << '\n';
  }
  return 0;
}
