#include using namespace std; int main() { int h, w; cin >> h >> w; int sy, sx, gy, gx; cin >> sy >> sx >> gy >> gx; sx--; sy--; gx--; gy--; vector g(h); for (int i = 0; i < h; i++) cin >> g[i]; static int dist[50][50]; memset(dist, -1, sizeof(dist)); dist[sy][sx] = 0; queue> q; q.emplace(sy, sx); while (!q.empty()) { int y, x; tie(y, x) = q.front(); q.pop(); for (int i = 0; i < 4; i++) { int ny = y + (i - 2) % 2; int nx = x + (i - 1) % 2; if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue; if (abs(g[ny][nx] - g[y][x]) <= 1 && dist[ny][nx] == -1) { dist[ny][nx] = dist[y][x] + 1; q.emplace(ny, nx); } } for (int i = 0; i < 4; i++) { int ny = y + (i - 2) % 2 * 2; int nx = x + (i - 1) % 2 * 2; if (ny < 0 || nx < 0 || ny >= h || nx >= w) continue; if (abs(g[ny][nx] - g[y][x]) == 0 && dist[ny][nx] == -1) { dist[ny][nx] = dist[y][x] + 1; q.emplace(ny, nx); } } } puts(dist[gy][gx] != -1 ? "YES" : "NO"); }