#include using namespace std; #define REP(i,n) for(int i=0; i<(int)(n); i++) #define FOR(i,b,e) for (int i=(int)(b); i<(int)(e); i++) #define ALL(x) (x).begin(), (x).end() const double PI = acos(-1); int dy[] = {0, 1, 0, -1}; int dx[] = {1, 0, -1, 0}; int main() { ios_base::sync_with_stdio(0); cin.tie(0); int h, w; cin >> h >> w; int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; --sx, --sy, --gx, --gy; vector bd(h); REP(i, h) cin >> bd[i]; queue > q; vector > vis(h, vector(w)); vis[sx][sy] = true; q.emplace(sx, sy); while (!q.empty()) { int x, y; tie(x, y) = q.front(); q.pop(); // neighbor REP (k, 4) { int xt = x + dx[k]; int yt = y + dy[k]; if (xt < 0 || xt >= h) continue; if (yt < 0 || yt >= w) continue; if (abs(bd[x][y] - bd[xt][yt]) < 2 && !vis[xt][yt]) { vis[xt][yt] = true; q.emplace(xt, yt); } } // jump REP(k, 4) { int xt = x + 2 * dx[k]; int yt = y + 2 * dy[k]; if (xt < 0 || xt >= h) continue; if (yt < 0 || yt >= w) continue; if (bd[x][y] == bd[xt][yt] && bd[x][y] > bd[x+dx[k]][y+dy[k]] && !vis[xt][yt]) { vis[xt][yt] = true; q.emplace(xt, yt); } } } if (vis[gx][gy]) cout << "YES" << endl; else cout << "NO" << endl; return 0; }