func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxn = 10000;   vector<int> nei[maxn];   bool mark[maxn];   vector<int> nei2[maxn];   bool markk[maxn];   int n, m, comp = 0, comp2 = 0;   void dfs(int v) {     mark[v] = true;     for (int i = 0; i < nei[v].size(); i++) {       int u = nei[v][i];       if (!mark[u]) dfs(u);     }     return;   }   bool dfs_all() {     for (int d = 0; d < n * m; d++) {       if (!mark[d]) {         dfs(d);         comp++;       }     }     if (comp == 1)       return true;     else       return false;   }   void dfs2(int v) {     markk[v] = true;     for (int p = 0; p < nei2[v].size(); p++) {       int u = nei2[v][p];       if (!markk[u]) {         dfs2(u);       }     }     return;   }   bool dfs2_all() {     for (int j = 0; j < n * m; j++) {       if (!markk[j]) {         dfs2(j);         comp2++;       }     }     if (comp2 == 1)       return true;     else       return false;   }   int main() {     string hor, ver;     cin >> n >> m;     cin >> hor >> ver;     for (int j = 0; j < n; j++) {       if (hor[j] ==  > ) {         for (int p = j * m; p < j * m + m - 1; p++) {           nei[p].push_back(p + 1);           nei2[p + 1].push_back(p);         }       } else {         for (int p = j * m + m - 1; p > j * m; p--) {           nei[p].push_back(p - 1);           nei2[p - 1].push_back(p);         }       }     }     for (int j = 0; j < m; j++) {       if (ver[j] ==  v ) {         for (int p = j; p < (n - 1) * m + j; p += m) {           nei[p].push_back(p + m);           nei2[p + m].push_back(p);         }       } else {         for (int p = (n - 1) * m + j; p > j; p -= m) {           nei[p].push_back(p - m);           nei2[p - m].push_back(p);         }       }     }     if (dfs_all() && dfs2_all())       cout <<  YES   << endl;     else       cout <<  NO  << endl;     return 0;   }   