#include #define REP(i, x, n) for(int i = x; i < (int)(n); i++) #define rep(i, n) REP(i, 0, n) #define all(x) (x).begin(), (x).end() #define rall(x) (x).rbegin(), (x).rend() #define F first #define S second #define mp make_pair using namespace std; typedef long long ll; typedef unsigned long long ull; typedef pair P; const int dx[] = {1, -1, 0, 0}; const int dy[] = {0, 0, 1, -1}; struct State { int x, y, oFlg; State(int x, int y, int o): x(x), y(y), oFlg(o) {} }; int N, V, ox, oy; int L[200][200]; int maxV[200][200][2]; string solve() { memset(maxV, -1, sizeof(maxV)); queue Q; Q.push(State(0, 0, 0)); maxV[0][0][0] = V; while(!Q.empty()) { State stt = Q.front(); Q.pop(); rep(i, 4) { int nx = stt.x + dx[i]; int ny = stt.y + dy[i]; if(!(0 <= nx && nx < N && 0 <= ny && ny < N)) continue; int v = maxV[stt.y][stt.x][stt.oFlg] - L[ny][nx]; if(v <= 0) continue; if(nx == N - 1 && ny == N - 1) return "YES"; if(maxV[ny][nx][stt.oFlg] < v) { maxV[ny][nx][stt.oFlg] = v; Q.push(State(nx, ny, stt.oFlg)); } if(nx == ox && ny == oy && stt.oFlg == 0) { if(maxV[ny][nx][1] < v * 2) { maxV[ny][nx][1] = v * 2; Q.push(State(nx, ny, 1)); } } } } return "NO"; } int main() { // ios_base::sync_with_stdio(false); cin >> N >> V >> ox >> oy; ox--; oy--; rep(i, N) rep(j, N) cin >> L[i][j]; cout << solve() << endl; return 0; }