import pprint from collections import deque def main(): h, w = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) sx -= 1 sy -= 1 gx -= 1 gy -= 1 B = [] for i in range(h): B.append(list(map(int, list(input())))) if(sx == gx and sy == gy): print("YES") exit() seen1 = [[False for _ in range(w)] for _ in range(h)] seen2 = [[False for _ in range(w)] for _ in range(h)] dx = [-1, 1, 0, 0, -2, 2, 0, 0] dy = [0, 0, -1, 1, 0, 0, -2, 2] q = deque() q.append((sx, sy, 0)) while q: x, y, z = q.popleft() if z == 0: seen1[x][y] = True seen2[x][y] = True elif z == 1: seen1[x][y] = True elif z == 2: seen2[x][y] = True for i in range(8): nx = x + dx[i] ny = y + dy[i] if nx < 0 or nx >= h or ny < 0 or ny >= w: continue if i < 4: if abs(B[x][y] - B[nx][ny]) <= 1 and seen1[nx][ny] == False: if nx == gx and ny == gy: print("YES") exit() else: q.append((nx, ny, 1)) else: if B[x][y] == B[nx][ny] and seen2[nx][ny] == False: if nx == gx and ny == gy: print("YES") exit() else: q.append((nx, ny, 2)) print("NO") if __name__ == "__main__": main()