#include using namespace std; // #define int long long using ll=long long; using vi=vector; using vl=vector; using pii=pair; #define ITR(v,c) for(auto v=begin(c);v!=end(c);v++) #define FOR(v,a,n) for(int v=a;v<(int)(n);v++) #define FORE(x,arr) for(auto &x:arr) #define REP(v,n) FOR(v,0,n) #define RREP(v,n) for(int v=((int)(n)-1);v>=0;v--) #define ALL(c) begin(c),end(c) #define RALL(c) rbegin(c),rend(c) #define DUMP(x) cerr<<#x<<":="<<(x)<ostream&operator<<(ostream &os,const pair &p){ os<<"("<ostream&operator<<(ostream &os,const vector &v){ ITR(i,v)os<<*i<<(i==end(v)-1?"":" ");return os;} //------------------------------------------------------------------------------ bool r[51][51]; signed main() { int h,w; pii s,g; cin>>h>>w; cin>>s.first>>s.second; s.first--; s.second--; cin>>g.first>>g.second; g.first--; g.second--; vector b(h); REP(i,h) cin>>b[i]; queue q; r[s.first][s.second]=true; q.push(s); while(!q.empty()) { pii p=q.front(); q.pop(); if(p==g) { cout<<"YES"<=h || nx<0 || nx>=w) continue; if(!r[ny][nx] && b[ny][nx]-b[p.first][p.second]<=1) { r[ny][nx]=true; q.push(pii(ny,nx)); } nx+=DX[i]; ny+=DY[i]; if(ny<0 || ny>=h || nx<0 || nx>=w) continue; if(!r[ny][nx] && b[ny][nx]==b[p.first][p.second] && b[ny-DY[i]][nx-DX[i]]