#include using namespace std; typedef long long ll; #define int ll const int dx[]={1,0,-1,0}; const int dy[]={0,1,0,-1}; int n,m,sx,sy,zx,zy,a[57][57]; bool vis[57][57]; queue>q; signed main(){ cin>>n>>m>>sx>>sy>>zx>>zy; for(int i=1;i<=n;i++) for(int j=1;j<=m;j++){ char ch;cin>>ch; a[i][j]=ch-'0'; } q.push({sx,sy}); vis[sx][sy]=1; while(!q.empty()){ int x=q.front().first; int y=q.front().second; if(x==zx&&y==zy){ puts("YES"); return 0; }q.pop(); for(int i=0;i<4;i++){ int tx=x+dx[i]; int ty=y+dy[i]; if(tx>=1 && tx<=n && ty>=1 && ty<=m && !vis[tx][ty]){ if(a[tx][ty]==a[x][y] || abs(a[tx][ty]-a[x][y])==1){ q.push({tx,ty}); vis[tx][ty]=1; } } int tx2=tx+dx[i]; int ty2=ty+dy[i]; if(tx2>=1 && tx2<=n && ty2>=1 && ty2<=m && !vis[tx2][ty2]){ if(a[tx2][ty2]==a[x][y] && a[tx][ty]