#include #define rep(i,n) for (int i = 0; i < (n); ++i) #define chmax(a, b) a = max(a, b) #define chmin(a, b) a = min(a, b) #define all(x) (x).begin(), (x).end() using namespace std; using ll = long long; using P = pair; using VI = vector; using VVI = vector; const int INF = 1e9; const int dx[] = {1,0,-1,0}; const int dy[] = {0,1,0,-1}; int main() { int n, v, ox, oy; cin >> n >> v >> oy >> ox; ox--; oy--; VVI l(n, VI(n)); rep(i, n) rep(j, n) cin >> l[i][j]; auto min_cost = [&](int sx, int sy, int gx, int gy) { VVI dp(n, VI(n, INF)); priority_queue> q; auto push = [&](int x, int y, int cost) { if (cost < dp[x][y]) { dp[x][y] = cost; q.emplace(-cost, x, y); } }; push(sx, sy, 0); while(!q.empty()) { int x, y, cost; tie(cost, x, y) = q.top(); q.pop(); cost = -cost; if (cost > dp[x][y]) continue; rep(k, 4) { int nx = x + dx[k], ny = y + dy[k]; if (!(0 <= nx && nx < n && 0 <= ny && ny < n)) continue; int nc = cost + l[nx][ny]; push(nx, ny, nc); } } return dp[gx][gy]; }; bool ok = false; if (min_cost(0, 0, n-1, n-1) < v) ok = true; if (ox >= 0) { int nv = v - min_cost(0, 0, ox, oy); if (nv > 0) { nv *= 2; if (min_cost(ox, oy, n-1, n-1) < nv) ok = true; } } cout << (ok ? "YES" : "NO") << endl; }