local mfl = math.floor local n, v, ox, oy = io.read("*n", "*n", "*n", "*n") local oidx = (oy - 1) * n + ox local map = {} for i = 1, n * n do map[i] = io.read("*n") end local function walk(src, dst, life, tasks) if life[dst] < life[src] - map[dst] then table.insert(tasks, dst) life[dst] = life[src] - map[dst] end end local function dig(srcidx, srcval, dstidx) local life = {} for i = 1, n * n do life[i] = 0 end life[srcidx] = srcval local tasks = {srcidx} local tasknum, done = 1, 0 while done < tasknum do done = done + 1 local curidx = tasks[done] if curidx % n ~= 0 then walk(curidx, curidx + 1, life, tasks) end if curidx % n ~= 1 then walk(curidx, curidx - 1, life, tasks) end if n < curidx then walk(curidx, curidx - n, life, tasks) end if curidx <= n * n - n then walk(curidx, curidx + n, life, tasks) end tasknum = #tasks end return life[dstidx] end local straight = dig(1, v, n * n) if 0 < straight then print("YES") else local f = false if 0 < oidx then local tooasis = dig(1, v, oidx) if 0 < tooasis then local toend = dig(oidx, tooasis * 2, n * n) if 0 < toend then print("YES") f = true end end end if not f then print("NO") end end