#!/usr/bin/env python3 # %% import sys read = sys.stdin.buffer.read readline = sys.stdin.buffer.readline readlines = sys.stdin.buffer.readlines # %% H, W = map(int, readline().split()) H += 4 W += 4 sx, sy, gx, gy = map(lambda x: int(x) + 1, readline().split()) INF = 20 A = [INF] * (H * W) for h in range(2, H - 2): A[h * W + 2:(h + 1) * W - 2] = map(int, readline().decode().rstrip()) # %% N = H * W graph = [[] for _ in range(N)] s = sx * W + sy g = gx * W + gy # %% for i in range(2, H - 2): for j in range(2, W - 2): v = i * W + j for dx in (1, -1, W, -W): if A[v] - A[v + dx] in (-1, 0, 1): graph[v].append(v + dx) if A[v] == A[v + dx + dx] and A[v] > A[v + dx]: graph[v].append(v + dx + dx) # %% visited = [False] * N visited[s] = True stack = [s] while stack: v = stack.pop() for w in graph[v]: if visited[w]: continue stack.append(w) visited[w] = True # %% answer = 'YES' if visited[g] else 'NO' print(answer)