from collections import deque h, w = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) sx, sy, gx, gy = sx-1, sy-1, gx-1, gy-1 b = [list(input()) for _ in range(h)] way = [(-1, 0), (1, 0), (0, -1), (0, 1)] dist = [[float('inf')]*w for _ in range(h)] dist[sx][sy] = 0 que = deque([(sx, sy)]) while que: x, y = que.popleft() hight = int(b[x][y]) for i, j in way: nx = x + i ny = y + j if 0 <= nx < h and 0 <= ny < w: nhight = int(b[nx][ny]) if -1 <= hight - nhight <= 1 and dist[nx][ny] == float('inf'): dist[nx][ny] = dist[x][y] + 1 que.append((nx, ny)) nx += i ny += j if 0 <= nx < h and 0 <= ny < w: nhight = int(b[nx][ny]) mhight = int(b[nx-i][ny-j]) if mhight < hight == nhight and dist[nx][ny] == float('inf'): dist[nx][ny] = dist[x][y] + 1 que.append((nx, ny)) if dist[gx][gy] != float('inf'): print('YES') else: print('NO')