#include <bits/stdc++.h>
std::vector<int> powers(10, 1);
void request() {
  std::map<std::pair<int, int>, int> field;
  int length;
  std::cin >> length;
  int best_length = INT32_MAX;
  std::pair<int, int> best{-1, -1};
  std::pair<int, int> current{0, 0};
  field[current] = 0;
  for (int i = 1; i <= length; ++i) {
    char dir;
    std::cin >> dir;
    switch (dir) {
      case 'U':
        current.second += 1;
        break;
      case 'R':
        current.first += 1;
        break;
      case 'D':
        current.second -= 1;
        break;
      case 'L':
        current.first -= 1;
        break;
    }
    if (field.count(current)) {
      if (i - field[current] < best_length) {
        best.first = field[current];
        best.second = i;
        best_length = best.second - best.first;
      }
    }
    field[current] = i;
  }
  if (best_length != INT32_MAX) {
    std::cout << best.first + 1 << ' ' << best.second << '\n';
  } else {
    std::cout << "-1\n";
  }
}
int main() {
  int n;
  std::cin >> n;
  for (int i = 1; i < 10; ++i) {
    powers[i] = powers[i - 1] * 10;
  }
  for (int i = 0; i < n; ++i) {
    request();
  }
  return 0;
}
