#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9 + 7;
template <class T, class U>
inline void add_self(T &a, U b) {
  a += b;
  if (a >= mod) a -= mod;
  if (a < 0) a += mod;
}
template <class T, class U>
inline void min_self(T &x, U y) {
  if (y < x) x = y;
}
template <class T, class U>
inline void max_self(T &x, U y) {
  if (y > x) x = y;
}
template <typename T>
void print(T v, bool show_index = false) {
  int w = 2;
  if (show_index) {
    for (int i = 0; i < v.size(); i++) cout << setw(w) << i << " ";
    cout << endl;
  }
  for (auto i = v.begin(); i != v.end(); i++) cout << setw(w) << *i << " ";
  cout << endl;
}
template <typename T>
void print_vv(T v) {
  if (v.size() == 0) {
    cout << "Empty" << endl;
    return;
  }
  int w = 3;
  cout << setw(w) << " ";
  for (int j = 0; j < v[0].size(); j++) cout << setw(w) << j << " ";
  cout << endl;
  for (auto i = 0; i < v.size(); i++) {
    cout << i << " {";
    for (auto j = 0; j != v[i].size(); j++) {
      cout << setw(w) << v[i][j] << ",";
    }
    cout << "}," << endl;
  }
  cout << endl;
}
template <class T, class U>
void print_m(map<T, U> m, int w = 3) {
  if (m.empty()) {
    cout << "Empty" << endl;
    return;
  }
  for (auto x : m) cout << "(" << x.first << ": " << x.second << ")," << endl;
  cout << endl;
}
int main() {
  map<char, pair<int, int> > dir;
  dir['L'] = {-1, 0};
  dir['R'] = {1, 0};
  dir['U'] = {0, 1};
  dir['D'] = {0, -1};
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int t, n;
  cin >> t;
  while (t--) {
    cin >> n;
    pair<int, int> beg = {0, 0};
    map<pair<int, int>, int> seen;
    seen[beg] = 0;
    pair<int, int> ans = {-1, -1};
    int len = INT_MAX;
    string s;
    cin >> s;
    for (int i = 0; i < int(n); i++) {
      char c = s[i];
      beg.first += dir[c].first;
      beg.second += dir[c].second;
      if (seen.count(beg)) {
        int clen = i + 1 - seen[beg] + 1;
        if (clen < len) {
          len = clen;
          ans = {seen[beg] + 1, i + 1};
        }
      }
      seen[beg] = i + 1;
    }
    if (len != INT_MAX) {
      cout << ans.first << " " << ans.second << endl;
    } else {
      cout << -1 << endl;
    }
  }
  return 0;
}
