h, w = list(map(int, input().split())) sy, sx, gy, gx = list(map(int, input().split())) b = [] for _ in range(h): b.append(input().strip()) f = [[True] * w for _ in range(h)] t = [[sy - 1, sx - 1]] f[sy - 1][sx - 1] = False while len(t) > 0: s = [] for y, x in t: p = int(b[y][x]) if x > 0: q = int(b[y][x - 1]) if f[y][x - 1] and abs(p - q) < 2: f[y][x - 1] = False s.append([y, x - 1]) if y > 0: q = int(b[y - 1][x]) if f[y - 1][x] and abs(p - q) < 2: f[y - 1][x] = False s.append([y - 1, x]) if x < w - 1: q = int(b[y][x + 1]) if f[y][x + 1] and abs(p - q) < 2: f[y][x + 1] = False s.append([y, x + 1]) if y < h - 1: q = int(b[y + 1][x]) if f[y + 1][x] and abs(p - q) < 2: f[y + 1][x] = False s.append([y + 1, x]) if x > 1: q1 = int(b[y][x - 1]) q2 = int(b[y][x - 2]) if f[y][x - 2] and p > q1 and p == q2: f[y][x - 2] = False s.append([y, x - 2]) if y > 1: q1 = int(b[y - 1][x]) q2 = int(b[y - 2][x]) if f[y - 2][x] and p > q1 and p == q2: f[y - 2][x] = False s.append([y - 2, x]) if x < w - 2: q1 = int(b[y][x + 1]) q2 = int(b[y][x + 2]) if f[y][x + 2] and p > q1 and p == q2: f[y][x + 2] = False s.append([y, x + 2]) if y < h - 2: q1 = int(b[y + 1][x]) q2 = int(b[y + 2][x]) if f[y + 2][x] and p > q1 and p == q2: f[y + 2][x] = False s.append([y + 2, x]) t = s if f[gy - 1][gx - 1] == False: break print('NO' if f[gy - 1][gx - 1] else 'YES')