H, W = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) sx -= 1 sy -= 1 gx -= 1 gy -= 1 G = [tuple(map(int, list(input()))) for _ in range(H)] DX = (-1, 0, 1, 0, -1, -1, 1, 1) DY = (0, 1, 0, -1, -1, 1, -1, 1) DX = DX[:4] DY = DY[:4] vis = [[0] * W for _ in range(H)] vis[sx][sy] = 1 q = [(sx, sy)] while q: x, y = q.pop() now = G[x][y] for dx, dy in zip(DX, DY): nx = x + dx ny = y + dy if 0 <= nx < H and 0 <= ny < W: if not vis[nx][ny]: nxt = G[nx][ny] if abs(nxt - now) <= 1: vis[nx][ny] = 1 q.append((nx, ny)) nnx = nx + dx nny = ny + dy if 0 <= nnx < H and 0 <= nny < W: if not vis[nnx][nny]: nxt = G[nx][ny] nxtnxt = G[nnx][nny] if now == nxtnxt and now > nxt: vis[nnx][nny] = 1 q.append((nnx, nny)) if vis[gx][gy]: print("YES") else: print("NO")