import sys from collections import deque sys.setrecursionlimit(10**7) def I(): return int(sys.stdin.readline().rstrip()) def MI(): return map(int,sys.stdin.readline().rstrip().split()) def LI(): return list(map(int,sys.stdin.readline().rstrip().split())) def LI2(): return list(map(int,sys.stdin.readline().rstrip())) def S(): return sys.stdin.readline().rstrip() def LS(): return list(sys.stdin.readline().rstrip().split()) def LS2(): return list(sys.stdin.readline().rstrip()) H,W = MI() sx,sy,gx,gy = MI() B = [[0]*(W+1)]+[[0]+LI2() for _ in range(H)] flag = [[0]*(W+1) for _ in range(H+1)] flag[sx][sy] = 1 deq = deque([(sx,sy)]) while deq: x,y = deq.pop() if 1 <= x-1 <= H and flag[x-1][y] == 0 and abs(B[x-1][y]-B[x][y]) <= 1: flag[x-1][y] = 1 deq.appendleft((x-1,y)) if 1 <= x+1 <= H and flag[x+1][y] == 0 and abs(B[x+1][y]-B[x][y]) <= 1: flag[x+1][y] = 1 deq.appendleft((x+1,y)) if 1 <= y-1 <= W and flag[x][y-1] == 0 and abs(B[x][y-1]-B[x][y]) <= 1: flag[x][y-1] = 1 deq.appendleft((x,y-1)) if 1 <= y+1 <= W and flag[x][y+1] == 0 and abs(B[x][y+1]-B[x][y]) <= 1: flag[x][y+1] = 1 deq.appendleft((x,y+1)) if 1 <= x-2 <= H and flag[x-2][y] == 0 and B[x-2][y] == B[x][y] and B[x-1][y] < B[x][y]: flag[x-2][y] = 1 deq.appendleft((x-2,y)) if 1 <= x+2 <= H and flag[x+2][y] == 0 and B[x+2][y] == B[x][y] and B[x+1][y] < B[x][y]: flag[x+2][y] = 1 deq.appendleft((x+2,y)) if 1 <= y-2 <= W and flag[x][y-2] == 0 and B[x][y-2] == B[x][y] and B[x][y-1] < B[x][y]: flag[x][y-2] = 1 deq.appendleft((x,y-2)) if 1 <= y+2 <= W and flag[x][y+2] == 0 and B[x][y+2] == B[x][y] and B[x][y+1] < B[x][y]: flag[x][y+2] = 1 deq.appendleft((x,y+2)) if flag[gx][gy]: print('YES') else: print('NO')