#include using namespace std; int done[200][200]; int L[200][200]; int dx[] = {-1,0,1,0}; int dy[] = {0,1,0,-1}; struct NODE{ int x,y,c; }; bool operator < (const NODE &a,const NODE &b){ return a.c > b.c; } int main(){ int N,V,Ox,Oy; cin >> N >> V >> Ox >> Oy; --Ox,--Oy; for(int i = 0 ; i < N ; i++) for(int j = 0 ; j < N ; j++) cin >> L[i][j]; priority_queue Q; int V2 = -1; Q.push({0,0,0}); while( Q.size() ){ auto q = Q.top(); Q.pop(); if( done[q.y][q.x]++ ) continue; if( q.c >= V ) continue; if( q.y == N - 1 && q.x == N - 1 ){ cout << "YES" << endl; return 0; } if( q.y == Oy && q.x == Ox ){ V2 = max(V2,2*(V - q.c)); } for(int i = 0 ; i < 4 ; i++){ int tx = q.x + dx[i]; int ty = q.y + dy[i]; if( tx < 0 || tx >= N || ty >= N || ty < 0 ) continue; Q.push({tx,ty,q.c+L[ty][tx]}); } } memset(done,0,sizeof(done)); Q.push({Ox,Oy,0}); while( Q.size() ){ auto q = Q.top(); Q.pop(); if( done[q.y][q.x]++ ) continue; if( q.c >= V2 ) continue; if( q.y == N - 1 && q.x == N - 1 ){ cout << "YES" << endl; return 0; } for(int i = 0 ; i < 4 ; i++){ int tx = q.x + dx[i]; int ty = q.y + dy[i]; if( tx < 0 || tx >= N || ty >= N || ty < 0 ) continue; Q.push({tx,ty,q.c+L[ty][tx]}); } } cout << "NO" << endl; }