#include using namespace std; using ll = long long; #define rep(i, s, e) for (int i = (int)s; i < (int)e; ++i) #define all(a) (a).begin(), (a).end() vector dx = {0, 1, 0, -1}; vector dy = {1, 0, -1, 0}; template bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; } int main() { cin.tie(nullptr); int N, V, Ox, Oy; cin >> N >> V >> Ox >> Oy; vector L(N, vector(N)); rep(i, 0, N) rep(j, 0, N) cin >> L[i][j]; vector d(N, vector(N, 1 << 25)); priority_queue>, vector>>, greater>>> que; d[0][0] = 0; que.push({0, {0, 0}}); while (!que.empty()) { int dist; pair v; tie(dist, v) = que.top(); que.pop(); if (dist > d[v.first][v.second]) continue; rep(i, 0, 4) { int x = v.second + dx[i]; int y = v.first + dy[i]; if (x < 0 || N <= x || y < 0 || N <= y) continue; if (chmin(d[y][x], d[v.first][v.second] + L[y][x])) { que.push({d[y][x], {y, x}}); } } } if (V - d[N - 1][N - 1] > 0) { cout << "YES\n"; return 0; } else if (Ox == 0 && Oy == 0) { cout << "NO\n"; return 0; } V -= d[Oy - 1][Ox - 1]; V *= 2; vector d2(N, vector(N, 1 << 25)); d2[Oy - 1][Ox - 1] = 0; que.push({0, {Oy - 1, Ox - 1}}); while (!que.empty()) { int dist; pair v; tie(dist, v) = que.top(); que.pop(); if (dist > d2[v.first][v.second]) continue; rep(i, 0, 4) { int x = v.second + dx[i]; int y = v.first + dy[i]; if (x < 0 || N <= x || y < 0 || N <= y) continue; if (chmin(d2[y][x], d2[v.first][v.second] + L[y][x])) { que.push({d2[y][x], {y, x}}); } } } if (V - d2[N - 1][N - 1] > 0) cout << "YES\n"; else cout << "NO\n"; }