#include <bits/stdc++.h>   using namespace std;   namespace kotespace {   template <class T>   class duplet {    private:    public:     T x, y;     duplet(){};     duplet(T a, T b) : x(a), y(b){};     bool operator<(const duplet P) const {       return (x < P.x || (x == P.x && y < P.y));     }     bool operator>(const duplet P) const {       return (x > P.x || (x == P.x && y > P.y));     }     bool operator==(const duplet P) const { return (x == P.x && y == P.y); }     bool operator!=(const duplet P) const { return (x != P.x || y != P.y); }     void reverse() { std::swap(x, y); }   };   template <class P>   istream &operator>>(istream &in, duplet<P> &T) {     return (in >> T.x >> T.y);   }   template <class P>   ostream &operator<<(ostream &out, duplet<P> T) {     return (out << T.x <<     << T.y);   }   template <class T>   class triplet {    private:    public:     T x, y, z;     triplet(){};     triplet(T a, T b, T c) : x(a), y(b), z(c){};     bool operator<(const triplet P) const {       return (x < P.x || (x == P.x && y < P.y) ||               (x == P.x && y == P.y && z < P.z));     }     bool operator>(const triplet P) const {       return (x > P.x || (x == P.x && y > P.y) ||               (x == P.x && y == P.y && z > P.z));     }     bool operator==(const triplet P) const {       return (x == P.x && y == P.y && z == P.z);     }     bool operator!=(const triplet P) const {       return (x != P.x || y != P.y || z != P.z);     }     void reverse() { std::swap(x, z); }     void cycle_right(int a) {       if (a == 1) {         std::swap(x, y);         std::swap(x, z);       }       if (a == 2) {         std::swap(x, z);         std::swap(y, x);       }     }     void cycle_left(int a) {       if (a == 1) {         std::swap(x, z);         std::swap(y, x);       }       if (a == 2) {         std::swap(x, y);         std::swap(x, z);       }     }   };   template <class P>   istream &operator>>(istream &in, triplet<P> &T) {     return (in >> T.x >> T.y >> T.z);   }   template <class P>   ostream &operator<<(ostream &out, triplet<P> &T) {     return (out << T.x <<     << T.y <<     << T.z);   }   }  // namespace kotespace   using namespace kotespace;   long long inf = 1000 * 1000 * 1000 + 7;   long long inf64 = inf * inf;   long long mod = 228228227;   float START_TIME;   namespace std {   template <>   struct hash<duplet<int>> {     size_t operator()(const duplet<int> &k) const {       return (size_t)(k.x) * 102931204 + (size_t)(k.y) * 434823123;     }   };   }  // namespace std   int main() {     ios_base::sync_with_stdio(false);     cin.tie(NULL);     cout.tie(NULL);     cerr << fixed << setprecision(8);     cout << fixed << setprecision(8);     srand(time(0));     START_TIME = clock();     int t;     cin >> t;     while (t-- > 0) {       int n;       cin >> n;       string s;       cin >> s;       int balx = 0, baly = 0;       map<pair<int, int>, vector<int>> q;       long long l = -inf, r = inf;       q[make_pair(0, 0)].push_back(0);       for (int i = 0; i < n; ++i) {         if (s[i] ==  L ) ++balx;         if (s[i] ==  R ) --balx;         if (s[i] ==  U ) ++baly;         if (s[i] ==  D ) --baly;         q[make_pair(balx, baly)].push_back(i + 1);       }       for (auto &c : q) {         for (int i = 0; i + 1 < c.second.size(); ++i) {           if (c.second[i + 1] - c.second[i] < r - l) {             r = c.second[i + 1];             l = c.second[i];           }         }       }       if (r == inf)         cout << -1 << endl;       else         cout << l + 1 <<     << r << endl;     }     cerr << endl << (clock() - START_TIME) / CLOCKS_PER_SEC <<   sec.  << endl;   }