#include typedef long long ll; using namespace std; int H, W, Sx, Sy, Gx, Gy; vector B(51); bool dp[51][51] = {{0}}; void rec(int x = Sx - 1, int y = Sy - 1, int high = B[Sy - 1][Sx - 1] - '0'){ if(x <= -1 || x >= W || y <= -1 || y >= H) return; if(high != B[y][x] - '0') return; if(x == Gx - 1 && y == Gy- 1){ cout << "YES" << endl; exit(0); } if(dp[y][x]) return; dp[y][x] = true; rec(x - 1, y, high); rec(x + 1, y, high); rec(x, y - 1, high); rec(x, y + 1, high); rec(x - 1, y, high + 1); rec(x + 1, y, high + 1); rec(x, y - 1, high + 1); rec(x, y + 1, high + 1); rec(x - 1, y, high - 1); rec(x + 1, y, high - 1); rec(x, y - 1, high - 1); rec(x, y + 1, high - 1); if(x - 1 >= 0 && high > B[y][x - 1] - '0') rec(x - 2, y, high); if(x + 1 >= 0 && high > B[y][x + 1] - '0') rec(x + 2, y, high); if(y - 1 >= 0 && high > B[y - 1][x] - '0') rec(x, y - 2, high); if(y + 1 >= 0 && high > B[y + 1][x] - '0') rec(x, y + 2, high); return; } int main(void){ cin >> H >> W >> Sy >> Sx >> Gy >> Gx; for(int i = 0; i < H; ++i) cin >> B[i]; rec(); cout << "NO" << endl; return 0; }