h, w = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) B = [[int(i) for i in input()] for i in range(h)] visited = [[0] * w + [1, 1] for i in range(h)] + [[1] * (w + 2)] * 2 from collections import deque que = deque([sx - 1, sy - 1]) visited[sx - 1][sy - 1] = 1 while que: q1, q2 = que.popleft(), que.popleft() h = B[q1][q2] if visited[q1 + 1][q2] == 0 and abs(B[q1 + 1][q2] - h) < 2: visited[q1 + 1][q2] = 1 que.extend([q1 + 1, q2]) if visited[q1 - 1][q2] == 0 and abs(B[q1 - 1][q2] - h) < 2: visited[q1 - 1][q2] = 1 que.extend([q1 - 1, q2]) if visited[q1][q2 + 1] == 0 and abs(B[q1][q2 + 1] - h) < 2: visited[q1][q2 + 1] = 1 que.extend([q1, q2 + 1]) if visited[q1][q2 - 1] == 0 and abs(B[q1][q2 - 1] - h) < 2: visited[q1][q2 - 1] = 1 que.extend([q1, q2 - 1]) if visited[q1 + 2][q2] == 0 and B[q1 + 2][q2] == h and B[q1 + 1][q2] < h: visited[q1 + 2][q2] = 1 que.extend([q1 + 2, q2]) if visited[q1 - 2][q2] == 0 and B[q1 - 2][q2] == h and B[q1 - 1][q2] < h: visited[q1 - 2][q2] = 1 que.extend([q1 - 2, q2]) if visited[q1][q2 + 2] == 0 and B[q1][q2 + 2] == h and B[q1][q2 + 1] < h: visited[q1][q2 + 2] = 1 que.extend([q1, q2 + 2]) if visited[q1][q2 - 2] == 0 and B[q1][q2 - 2] == h and B[q1][q2 - 1] < h: visited[q1][q2 - 2] = 1 que.extend([q1, q2 - 2]) if visited[gx - 1][gy - 1]: print('YES') else: print('NO')