#include using namespace std; int h, w, sx, sy, gx, gy; const int MAX = 55; int B[MAX][MAX]; int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; bool seen[MAX][MAX]; void dfs(int x, int y){ seen[x][y] = true; for(int i = 0; i < 2; i++){ for(int j = 0; j < 4; j++){ int nx, ny; nx = x + dx[j] * (i + 1); ny = y + dy[j] * (i + 1); if(nx < 0 or nx >= h or ny < 0 or ny >= w) continue; if(seen[nx][ny]) continue; if(i == 0){ if(abs(B[x][y] - B[nx][ny]) > 1) continue; }else{ int bet = B[(x + nx) / 2][(y + ny) / 2]; if(B[x][y] != B[nx][ny] or B[x][y] < bet) continue; } dfs(nx, ny); } } } int main(){ cin.tie(0); ios::sync_with_stdio(false); cin >> h >> w; cin >> sx >> sy >> gx >> gy; sx--; sy--; gx--; gy--; for(int i = 0; i < h; i++){ string s; cin >> s; for(int j = 0; j < w; j++){ B[i][j] = s[j] - '0'; } } dfs(sx, sy); if(seen[gx][gy]) cout << "YES" << endl; else cout << "NO" << endl; return 0; }