h, w = map(int,input().split()) sx, sy, gx, gy = map(int,input().split()) sx -= 1 sy -= 1 gx -= 1 gy -= 1 b = [list(input()) for j in range(h)] dx = [ 1, 0,-1, 0] dy = [ 0, 1, 0,-1] ddx = [2, 0,-2, 0] ddy = [0, 2, 0,-2] visited = [[False] * w for j in range(h)] visited[sx][sy] = True qx = [] qy = [] qx.append(sx) qy.append(sy) while len(qx) != 0: curx = qx.pop(0) cury = qy.pop(0) cur = int(b[curx][cury]) for i in range(4): nextx = curx + dx[i] nexty = cury + dy[i] if 0 <= nextx < h and 0 <= nexty < w: pass else: continue if abs(cur - int(b[nextx][nexty])) <= 1: if not visited[nextx][nexty]: visited[nextx][nexty] = True qx.append(nextx) qy.append(nexty) for i in range(4): nextx = curx + ddx[i] nexty = cury + ddy[i] if 0 <= nextx < h and 0 <= nexty < w: pass else: continue if cur != int(b[nextx][nexty]): continue valleyx = curx + dx[i] valleyy = cury + dy[i] if int(b[valleyx][valleyy]) < cur: if not visited[nextx][nexty]: visited[nextx][nexty] = True qx.append(nextx) qy.append(nexty) if visited[gx][gy]: print("YES") else: print("NO")