#include <bits/stdc++.h>
using namespace std;
const long long oo = 1e8;
const double pi = 3.1415926535897;
const double EPS = (1e-7);
int dcmp(double x, double y) { return fabs(x - y) <= EPS ? 0 : x < y ? -1 : 1; }
struct edge {
  int from, to, w;
  edge() {}
  edge(int x, int y, int we) : from(x), to(y), w(we) {}
  bool operator<(const edge &rhs) const { return w > rhs.w; }
};
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  int t;
  cin >> t;
  while (t--) {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<int, int>, int> mp = {{{0, 0}, 1}};
    int i = 1;
    int x = 0, y = 0, ans = 2e6 + 5, l, r;
    for (auto let : s) {
      if (let == 'U')
        y++;
      else if (let == 'D')
        y--;
      else if (let == 'R')
        x++;
      else
        x--;
      int loc = mp[{x, y}];
      if (loc) {
        if (i - loc + 1 < ans) {
          ans = i - loc + 1;
          l = loc;
          r = i;
        }
      }
      mp[{x, y}] = ++i;
    }
    if (ans == (2e6 + 5))
      cout << "-1\n";
    else
      cout << l << " " << r << "\n";
  }
}
