func_code_string: #include <bits/stdc++.h>   using namespace std;   int n;   string s;   pair<int, int> best;   map<pair<int, int>, int> visited, mark;   void dfs(int i, int x, int y) {     if (i == n) {       return;     }     if (mark[make_pair(x, y)] == 0) {       mark[make_pair(x, y)] = 1;       visited[make_pair(x, y)] = i;       pair<int, int> move;       if (s[i] ==  L ) {         dfs(i + 1, x, y - 1);         move = {0, -1};       } else if (s[i] ==  R ) {         dfs(i + 1, x, y + 1);         move = {0, 1};       } else if (s[i] ==  U ) {         dfs(i + 1, x - 1, y);         move = {-1, 0};       } else if (s[i] ==  D ) {         dfs(i + 1, x + 1, y);         move = {1, 0};       }       if (visited.count({x + move.first, y + move.second})) {         auto val = visited[make_pair(x + move.first, y + move.second)];         cerr <<  found cycle   << val << endl;         if (i - val < best.second) {           best.first = val;           best.second = i - val;         }       }     }     visited.erase(visited.find(make_pair(x, y)));   }   void solve() {     cin >> n >> s;     best = {-1, 1e9};     map<pair<int, int>, int> seen;     pair<int, int> was = {0, 0};     seen[was] = 0;     for (int i = 1; i <= n; ++i) {       if (s[i - 1] ==  L )         was.second--;       else if (s[i - 1] ==  R )         was.second++;       else if (s[i - 1] ==  U )         was.first--;       else if (s[i - 1] ==  D )         was.first++;       if (seen.count(was)) {         auto index = seen[was];         int length = i - index;         if (best.second > length) {           best.first = index;           best.second = length;         }       }       seen[was] = i;     }     if (best.first == -1) {       cout << -1 << endl;     } else {       cout << best.first + 1 <<     << best.first + best.second << endl;     }   }   int main() {     int t;     cin >> t;     while (t--) solve();   }   