#include <bits/stdc++.h>   using namespace std;   template <typename F, typename S>   ostream &operator<<(ostream &os, const pair<F, S> &p) {     return os <<  (  << p.first <<  ,   << p.second <<  ) ;   }   template <typename T>   ostream &operator<<(ostream &os, const vector<T> &v) {     os <<  { ;     typename vector<T>::const_iterator it;     for (it = v.begin(); it != v.end(); it++) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  } ;   }   template <typename T>   ostream &operator<<(ostream &os, const set<T> &v) {     os <<  [ ;     typename set<T>::const_iterator it;     for (it = v.begin(); it != v.end(); it++) {       if (it != v.begin()) os <<  ,  ;       os << *it;     }     return os <<  ] ;   }   template <typename F, typename S>   ostream &operator<<(ostream &os, const map<F, S> &v) {     os <<  [ ;     typename map<F, S>::const_iterator it;     for (it = v.begin(); it != v.end(); it++) {       if (it != v.begin()) os <<  ,  ;       os << it->first <<   =   << it->second;     }     return os <<  ] ;   }   int n, m;   string hor, ver;   int give_dir(char ch) {     if (ch ==  >  || ch ==  v )       return 1;     else       return -1;   }   bool valid(int x, int y) {     if (x < 0 || y < 0 || x >= n || y >= m) return false;     return true;   }   void dfs(int x, int y, vector<vector<bool> > &visited) {     visited[x][y] = true;     int nx, ny;     nx = x + give_dir(ver[y]);     ny = y + give_dir(hor[x]);     if (valid(nx, y) && !visited[nx][y]) dfs(nx, y, visited);     if (valid(x, ny) && !visited[x][ny]) dfs(x, ny, visited);   }   int main() {     cin >> n >> m;     cin >> hor >> ver;     for (int k = 0; k < (n); k++) {       for (int l = 0; l < (m); l++) {         vector<vector<bool> > visited(n, vector<bool>(m, false));         dfs(k, l, visited);         for (int i = 0; i < (n); i++) {           for (int j = 0; j < (m); j++) {             if (!visited[i][j]) {               cout <<  NO  << endl;               return 0;             }           }         }       }     }     cout <<  YES  << endl;     return 0;   }   