local ior = io.input() local h, w = ior:read("*n", "*n") local sh, sw, gh, gw = ior:read("*n", "*n", "*n", "*n", "*l") local str = "" local map = {} local state = {} local function getindex(xh, xw) return (xh - 1) * w + xw end local cue = {getindex(sh, sw)} state[getindex(sh, sw)] = true local tasks, done = 1, 0 local function walk(src, dst) if (math.abs(map[src] - map[dst]) <= 1) then if(not state[dst]) then state[dst] = true tasks = tasks + 1 table.insert(cue, dst) end end end local function ladder(src, mid, dst) if(map[src] == map[dst] and map[mid] < map[src]) then if(not state[dst]) then state[dst] = true tasks = tasks + 1 table.insert(cue, dst) end end end for i = 1, h do str = ior:read() for j = 1, w do local tmp = tonumber(str:sub(j, j)) local tmp2 = getindex(i, j) map[tmp2] = tmp state[tmp2] = false end end while(done < tasks) do done = done + 1 local idx = cue[done] if(w < idx) then walk(idx, idx - w) end if(idx <= (h - 1) * w) then walk(idx, idx + w) end if(idx % w ~= 0) then walk(idx, idx + 1) end if(idx % w ~= 1) then walk(idx, idx - 1) end if(w * 2 < idx) then ladder(idx, idx - w, idx - 2 * w) end if(idx <= (h - 2) * w) then ladder(idx, idx + w, idx + 2 * w) end if(idx % w ~= 0 and idx % w ~= (w - 1)) then ladder(idx, idx + 1, idx + 2) end if(idx % w ~= 1 and idx % w ~= 2) then ladder(idx, idx - 1, idx - 2) end end print(state[getindex(gh, gw)] and "YES" or "NO")