class UnionFind(): def __init__(self, n): self.n = n self.par = list(range(self.n)) self.rank = [1] * n self.count = n def find(self, x): if self.par[x] == x: return x else: self.par[x] = self.find(self.par[x]) return self.par[x] def unite(self, x, y): p = self.find(x) q = self.find(y) if p == q: return None if p > q: p, q = q, p self.rank[p] += self.rank[q] self.par[q] = p self.count -= 1 def same(self, x, y): return self.find(x) == self.find(y) def size(self, x): return self.rank[x] def count(self): return self.count h, w = map(int, input().split()) sx, sy, gx, gy = map(int, input().split()) s = [list(map(int, list(input()))) for i in range(h)] UF = UnionFind(h * w) for i in range(h): for j in range(w - 1): if abs(s[i][j] - s[i][j + 1]) <= 1: UF.unite(i * w + j, i * w + j + 1) if j != w - 2 and s[i][j] == s[i][j + 2] > s[i][j + 1]: UF.unite(i * w + j, i * w + j + 2) for i in range(h - 1): for j in range(w): if abs(s[i][j] - s[i + 1][j]) <= 1: UF.unite(i * w + j, (i + 1) * w + j) if i != h - 2 and s[i][j] == s[i + 2][j] > s[i + 1][j]: UF.unite(i * w + j, (i + 2) * w + j) print("YES" if UF.same((sx - 1) * w + (sy - 1), (gx - 1) * w + (gy - 1)) else "NO")