#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 10;
int t, n;
char s[maxn];
map<pair<int, int>, int> mp;
int main() {
  ios::sync_with_stdio(false);
  cin >> t;
  while (t--) {
    mp.clear();
    cin >> n >> s + 1;
    int x = 0, y = 0, l, r, ans = inf;
    mp[pair<int, int>(0, 0)] = 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;
      if (mp.count(pair<int, int>(x, y))) {
        if (i - mp[pair<int, int>(x, y)] < ans) {
          ans = i - mp[pair<int, int>(x, y)];
          l = mp[pair<int, int>(x, y)] + 1;
          r = i;
        }
      }
      mp[pair<int, int>(x, y)] = i;
    }
    if (ans == inf)
      cout << -1 << endl;
    else
      cout << l << " " << r << endl;
  }
  return 0;
}
