func_code_string: #include <bits/stdc++.h>   using namespace std;   const int maxsize = 100;   int n, m;   bool visited[maxsize][maxsize];   string v, h;   int go[][2] = {1, 0, -1, 0, 0, -1, 0, 1};   map<char, int> dir;   int cnt;   void dfs(int row, int col) {     if (visited[row][col]) return;     visited[row][col] = true;     cnt++;     int n_row = -1, n_col = -1;     n_row = row + go[dir[h[row]]][0];     n_col = col + go[dir[h[row]]][1];     if (n_col >= 0 && n_col < m) {       dfs(n_row, n_col);     }     n_row = row + go[dir[v[col]]][0];     n_col = col + go[dir[v[col]]][1];     if (n_row >= 0 && n_row < n) {       dfs(n_row, n_col);     }   }   int main(int argc, char* argv[]) {     dir[ > ] = 3;     dir[ < ] = 2;     dir[ ^ ] = 1;     dir[ v ] = 0;     while (scanf( %d%d , &n, &m) != EOF) {       cin >> h >> v;       bool flag = true;       for (int ii = 0; ii < n && flag; ii++) {         for (int jj = 0; jj < m && flag; jj++) {           memset(visited, false, sizeof(visited));           cnt = 0;           dfs(ii, jj);           if (cnt != n * m) flag = false;         }       }       if (cnt == n * m)         printf( YES n );       else         printf( NO n );     }     return 0;   }   