from heapq import heappush, heappop def dijkstra(start,graph): INF = 10 ** 15 dist = [INF] * (n*n) dist[start] = 0 q = [(0,start)] while q: d,v = heappop(q) if dist[v] < d: continue for w,a in graph[v]: d1 = d + a if dist[w] > d1: dist[w] = d1 heappush(q, (d1,w)) return dist #このまま適当にはって使える感じではない? #隣接リスト適当に渡せば動く。重みを追加するのをわすれずに def check(s,t): if (0 <= s <= n - 1) and (0 <= t <= n - 1): return True else: return False def grid_2_graph(grid): adjacent_list = [[] for i in range(h*w)] for i in range(h): for j in range(w): for n_x,n_y in [(j+1,i),(j-1,i),(j,i+1),(j,i-1)]: if check(n_x,n_y): #(i,j) -> (n_y, n_x)に辺をつなぐ adjacent_list[i*w+j].append([(n_y)*w + (n_x),grid[n_y][n_x]]) return adjacent_list n,v,o_x,o_y = map(int,input().split()) h,w = n,n graph = [] for i in range(n): graph.append(list(map(int, input().split()))) graph = grid_2_graph(graph) dist_from_start = dijkstra(0,graph) oasis_node = 0 if o_x != 0 and o_y != 0: oasis_node = (o_x - 1) + (o_y - 1) * n dist_from_oasis = dijkstra(oasis_node,graph) ans = "NO" if dist_from_start[n*n-1] < v: ans = "YES" if o_x != o_y != 0: v -= dist_from_start[oasis_node] if v > 0: v *= 2 if dist_from_oasis[n*n-1] < v: ans = "YES" print(ans)