func_code_string: #include <bits/stdc++.h>   using namespace std;   void solve();   signed main() {     ios::sync_with_stdio(false);     cin.tie(0);     cout << fixed;     cout.precision(12);     solve();     return 0;   }   template <typename T>   void prv(vector<T> v) {     for (int __ii = 0; __ii < ((int)v.size()); __ii++) {       if (__ii) cout <<    ;       cout << v[__ii];     }     cout <<   n ;   }   template <typename T>   void prm(vector<vector<T>> v) {     for (int __ii = 0; __ii < ((int)v.size()); __ii++) {       for (int __jj = 0; __jj < v[__ii].size(); __jj++) {         if (__jj) cout <<    ;         cout << v[__ii][__jj];       }       cout <<   n ;     }   }   template <typename T>   void sc(T& x) {     cin >> x;   }   template <typename Head, typename... Tail>   void sc(Head& head, Tail&... tail) {     cin >> head;     sc(tail...);   }   template <typename T>   void pr(const T& x) {     cout << x <<   n ;   }   template <typename Head, typename... Tail>   void pr(const Head& head, const Tail&... tail) {     cout << head <<    ;     pr(tail...);   }   template <typename... T>   void err(const T&... cod) {     pr(cod...);     exit(0);   }   void solve() {     int n, m, y, x;     sc(n, m, y, x);     string s;     sc(s);     int dx = (s[1] ==  L  ? -1 : 1);     int dy = (s[0] ==  U  ? -1 : 1);     const int MAX_ITER = 1e6 + 10;     set<pair<int, int>> st;     long long ans = 1;     for (int i = 0; i < MAX_ITER; i++) {       st.emplace(y, x);       if (((int)st.size()) == n + m - 2) err(ans);       int u = (dy == -1 ? y - 1 : n - y);       int v = (dx == -1 ? x - 1 : m - x);       int w = min(u, v);       x += dx * w;       y += dy * w;       ans += w;       if (v == w) dx *= -1;       if (u == w) dy *= -1;     }     pr(-1);   }   