#include #define rep(i,n) for(int i = 0; i < (n); ++i) #define srep(i,s,t) for (int i = s; i < t; ++i) #define drep(i,n) for(int i = (n)-1; i >= 0; --i) using namespace std; typedef long long int ll; typedef pair P; #define yn {puts("YES");}else{puts("NO");} #define MAX_N 200005 int dx[4] = {-1, 0, 1, 0}; int dy[4] = {0, -1, 0, 1}; int main() { int n, v, ox, oy; cin >> n >> v >> ox >> oy; swap(ox,oy); int a[n+2][n+2]; int f[n+2][n+2][2]; rep(i,n+2){ rep(j,n+2){ if(i==0||i==n+1||j==0||j==n+1){ a[i][j] = 1001001001; }else{ cin >> a[i][j]; } f[i][j][0] = 0; f[i][j][1] = 0; } } priority_queue> que; pair p; p.first.first = v; p.first.second = 0; p.second.first = 1; p.second.second = 1; que.push(p); f[1][1][0] = v; while(que.size() > 0){ int v = que.top().first.first; int z = que.top().first.second; int x = que.top().second.first; int y = que.top().second.second; que.pop(); if(f[x][y][z] > v) continue; // cout << x << ' ' << y << ' ' << z << ' ' << v << endl; rep(i,4){ int nx = x + dx[i]; int ny = y + dy[i]; int nv = v - a[nx][ny]; if(nv <= f[nx][ny][z]) continue; if(nx==ox&&ny==oy){ nv *= 2; if(f[nx][ny][1] < nv){ f[nx][ny][1] = nv; p.first.first = nv; p.first.second = 1; p.second.first = nx; p.second.second = ny; que.push(p); } }else{ if(f[nx][ny][z] < nv){ f[nx][ny][z] = nv; p.first.first = nv; p.first.second = z; p.second.first = nx; p.second.second = ny; que.push(p); } } } } if(f[n][n][0]>0||f[n][n][1]>0) yn; return 0; }