475_B. Strongly Connected City
Imagine a city with n horizontal streets crossing m vertical streets, forming an (n - 1) × (m - 1) grid. In order to increase the traffic flow, mayor of the city has decided to make each street one way. This means in each horizontal street, the traffic moves only from west to east or only from east to west. Also, traffic moves only from north to south or only from south to north in each vertical street. It is possible to enter a horizontal street from a vertical street, or vice versa, at their intersection.

<image>

The mayor has received some street direction patterns. Your task is to check whether it is possible to reach any junction from any other junction in the proposed street direction pattern.

Input

The first line of input contains two integers n and m, (2 ≤ n, m ≤ 20), denoting the number of horizontal streets and the number of vertical streets.

The second line contains a string of length n, made of characters '<' and '>', denoting direction of each horizontal street. If the i-th character is equal to '<', the street is directed from east to west otherwise, the street is directed from west to east. Streets are listed in order from north to south.

The third line contains a string of length m, made of characters '^' and 'v', denoting direction of each vertical street. If the i-th character is equal to '^', the street is directed from south to north, otherwise the street is directed from north to south. Streets are listed in order from west to east.

Output

If the given pattern meets the mayor's criteria, print a single line containing "YES", otherwise print a single line containing "NO".

Examples

Input

3 3
&gt;&lt;&gt;
v^v


Output

NO


Input

4 6
&lt;&gt;&lt;&gt;
v^v^v^


Output

YES

Note

The figure above shows street directions in the second sample test case.
```python
import math,sys,bisect,heapq
from collections import defaultdict,Counter,deque
from itertools import groupby,accumulate
#sys.setrecursionlimit(200000000)
int1 = lambda x: int(x) - 1
#def input(): return sys.stdin.readline().strip()
input = iter(sys.stdin.buffer.read().decode().splitlines()).__next__
ilele = lambda: map(int,input().split())
alele = lambda: list(map(int, input().split()))
ilelec = lambda: map(int1,input().split())
alelec = lambda: list(map(int1, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
#MOD = 1000000000 + 7
def Y(c):  print(["NO","YES"][c])
def y(c):  print(["no","yes"][c])
def Yy(c):  print(["No","Yes"][c])

n,m = ilele()
S1 = input()
S2 = input()

V = n*m
INF = float('inf')

v = 0
Id = [[-1 for i in range(m)] for j in range(n)]
for i in range(n):
    for j in range(m):
        Id[i][j] = v
        v+=1
graph = [[INF]*(n*m) for i in range(n*m)]

def addEdge(a,b):
    i,j =a
    ii,jj =b
    id1 = Id[i][j]
    id2 = Id[ii][jj]
    graph[id1][id2] = 1

    
for i in range(n):
    for j in range(m):
        if i==0:
            if S1[i] == ">":
                if j!=m-1:
                    addEdge((i,j),(i,j+1))
            else:
                if j!=0:
                    addEdge((i,j),(i,j-1))
            if S2[j] == "v":
                if i!=n-1:
                    addEdge((i,j),(i+1,j))
        elif i == n-1:
            if S1[i] == ">":
                if j!=m-1:
                    addEdge((i,j),(i,j+1))
            else:
                if j!=0:
                    addEdge((i,j),(i,j-1))
            if S2[j] == "^":
                if i!=0:
                    addEdge((i,j),(i-1,j))
        else:
            if S1[i] == ">":
                if j!=m-1:
                    addEdge((i,j),(i,j+1))
            else:
                if j!=0:
                    addEdge((i,j),(i,j-1))
            if S2[j] == "^":
                if i!=0:
                    addEdge((i,j),(i-1,j))
            else:
                if i!= n-1:
                    addEdge((i,j),(i+1,j))

def floydWarshall(graph):
    dist = graph.copy()
    for k in range(V):
        for i in range(V):
            for j in range(V):
                dist[i][j] = min(dist[i][j],dist[i][k]+ dist[k][j])
    return dist

Ans = floydWarshall(graph)
for i in Ans:
    if INF in i:
        Y(0)
        exit(0)
Y(1)



```