#include "bits/stdc++.h" using namespace std; #define FOR(i,j,k) for(int (i)=(j);(i)<(int)(k);++(i)) #define rep(i,j) FOR(i,0,j) #define each(x,y) for(auto &(x):(y)) #define mp make_pair #define all(x) (x).begin(),(x).end() #define debug(x) cout<<#x<<": "<<(x)< pii; typedef vector vi; typedef vector vll; const int DY[] = {-1,0,1,0}; const int DX[] = {0,1,0,-1}; int vis[50][50]; string b[50]; int h, w; void f(int y, int x){ if(vis[y][x]++)return; int cur = b[y][x]; rep(i, 4){ int ny = y + DY[i], nx = x + DX[i]; if(ny >= 0 && nx >= 0 && ny < h&&nx < w){ if(abs(cur - b[ny][nx]) <= 1){ f(ny, nx); } int nny = y + DY[i] * 2, nnx = x + DX[i] * 2; if(cur > b[ny][nx] && nny >= 0 && nnx >= 0 && nny < h&&nnx < w && cur == b[nny][nnx]){ f(nny, nnx); } } } } int main(){ cin >> h >> w; int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; --sx; --sy; --gx; --gy; rep(y, h){ cin >> b[y]; } f(sx, sy); puts(vis[gx][gy] ? "YES" : "NO"); }