h,w = map(int,input().split())
sx,sy,gx,gy = map(int,input().split())
b = [list(map(int,input())) for _ in range(h)]

dist = [[-1]*w for _ in range(h)]
dist[sx-1][sy-1] = 1
q = [(sx-1,sy-1)]
while q:
    sx,sy = q.pop()
    for nx,ny in [(sx-1,sy),(sx+1,sy),(sx,sy-1),(sx,sy+1)]:
        if 0 <= nx < h and 0 <= ny < w and dist[nx][ny]==-1:
            if abs(b[nx][ny] - b[sx][sy]) <= 1:
                q.append((nx,ny))
                dist[nx][ny] = 1
    for nx,ny in [(sx-2,sy),(sx+2,sy),(sx,sy-2),(sx,sy+2)]:
        if 0 <= nx < h and 0 <= ny < w and dist[nx][ny]==-1:
            if b[nx][ny] == b[sx][sy] > b[(nx+sx)//2][(ny+sy)//2]:
                q.append((nx,ny))
                dist[nx][ny] = 1
print("YES" if dist[gx-1][gy-1]==1 else "NO")