type UnionFind(n) = let n = n let parent = [| 0 .. n - 1|] member this.Parent with get() = parent member this.Find x = if this.Parent.[x] <> x then this.Parent.[x] <- this.Find this.Parent.[x] this.Parent.[x] member this.Unite x y = this.Parent.[this.Find x] <- this.Find y member this.Same x y = (this.Find x) = (this.Find y) let h, w = System.Console.ReadLine().Split() |> Array.map int |> fun a -> a.[0], a.[1] let sy, sx, gy, gx = System.Console.ReadLine().Split() |> Array.map int |> Array.map ((+) -1) |> fun a -> a.[0], a.[1], a.[2], a.[3] let b = [|for i in 0 .. h - 1 -> System.Console.ReadLine().ToCharArray() |> Array.map int|] let uf = new UnionFind(h * w) for i = 0 to h - 1 do for j = 0 to w - 1 do for di, dj in [(0, 1); (1, 0); (0, -1); (-1, 0)] do let ii = i + di let jj = j + dj if 0 <= ii && ii < h && 0 <= jj && jj < w then if abs (b.[ii].[jj] - b.[i].[j]) <= 1 then uf.Unite (i * w + j) (ii * w + jj) for di, dj in [(0, 1); (1, 0); (0, -1); (-1, 0)] do let ii = i + di let jj = j + dj let iii = i + di * 2 let jjj = j + dj * 2 if 0 <= iii && iii < h && 0 <= jjj && jjj < w then if b.[ii].[jj] < b.[i].[j] && b.[iii].[jjj] = b.[i].[j] then uf.Unite (i * w + j) (iii * w + jjj) if uf.Same (sy * w + sx) (gy * w + gx) then "YES" else "NO" |> System.Console.WriteLine