#include <bits/stdc++.h>
using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int x = 0;
    int y = 0;
    int ans = -1;
    int ans2 = 1e9;
    map<pair<int, int>, int> mp;
    mp[{0, 0}] = 1;
    for (int i = 0; i < s.size(); i++) {
      if (s[i] == 'L')
        x--;
      else if (s[i] == 'R')
        x++;
      else if (s[i] == 'U')
        y++;
      else if (s[i] == 'D')
        y--;
      if (mp[{x, y}]) {
        if ((i + 1) - mp[{x, y}] < ans2 - ans) {
          ans = mp[{x, y}];
          ans2 = i + 1;
        }
      }
      mp[{x, y}] = i + 2;
    }
    if (ans == -1)
      cout << -1 << '\n';
    else
      cout << ans << " " << ans2 << "\n";
  }
}
