from collections import deque H, W = map(int, input().split()) sy, sx, gy, gx = map(lambda x: int(x) - 1, input().split()) S = [list(map(int, input())) for _ in range(H)] visited = [[False] * W for _ in range(H)] visited[sy][sx] = True direction = [(-1, 0), (0, 1), (1, 0), (0, -1), (-2, 0), (0, 2), (2, 0), (0, -2)] que = deque([(sy, sx)]) while que: y, x = que.popleft() for dy, dx in direction: ny, nx = y + dy, x + dx if 0 <= ny < H and 0 <= nx < W: if visited[ny][nx]: continue flg = False if abs(dy + dx) == 2: if S[ny][nx] == S[y][x]: flg = True else: if abs(S[ny][nx] - S[y][x]) <= 1: flg = True if flg: visited[ny][nx] = True que.append((ny, nx)) print("YES" if visited[gy][gx] else "NO")