from collections import deque D = [(1, 0), (0, 1), (-1, 0), (0, -1)] DD = [(2, 0), (0, 2), (-2, 0), (0, -2)] h, w = map(int, input().split()) si, sj, gi, gj = map(int, input().split()) si -= 1 sj -= 1 gi -= 1 gj -= 1 B = [list(map(int, list(input()))) for _ in range(h)] visited = [[False for _ in range(w)] for _ in range(h)] visited[si][sj] = True Que = deque([(si, sj)]) while Que: ci, cj = Que.popleft() if ci == gi and cj == gj: print("YES") exit() for di, dj in D: ni = ci + di nj = cj + dj if 0 <= ni < h and 0 <= nj < w and not visited[ni][nj]: if abs(B[ci][cj] - B[ni][nj]) <= 1: visited[ni][nj] = True Que.append((ni, nj)) for di, dj in DD: ni = ci + di nj = cj + dj if 0 <= ni < h and 0 <= nj < w and not visited[ni][nj]: mi = (ci + ni) // 2 mj = (cj + nj) // 2 if B[ci][cj] == B[ni][nj] and B[ci][cj] > B[mi][mj]: visited[ni][nj] = True Que.append((ni, nj)) print("NO")