import pprint 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())))) seen = [[False for _ in range(w)] for _ in range(h)] dx = [-1, 1, 0, 0] dy = [0, 0, -1, 1] dx2 = [-2, 2, 0, 0] dy2 = [0, 0, -2, 2] def dfs(x, y): if x == gx and y == gy: return True seen[x][y] = True for i in range(4): nx = x + dx[i] ny = y + dy[i] if nx < 0 or nx >= h or ny < 0 or ny >= w: continue if seen[nx][ny] or abs(B[x][y] - B[nx][ny]) > 1: continue if dfs(nx, ny): return True for i in range(4): nx = x + dx2[i] ny = y + dy2[i] if nx < 0 or nx >= h or ny < 0 or ny >= w: continue if seen[nx][ny] or B[x][y] != B[nx][ny]: continue if dfs(nx, ny): return True return False if dfs(sx, sy): print("YES") else: print("NO") #pprint.pprint(seen)