#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;
typedef pair<int, int> P;

int h, w;
int sy, sx, gy, gx;
int dy[4] = {1, -1, 0, 0};
int dx[4] = {0, 0, 1, -1};
int hy[4] = {2, -2, 0, 0};
int hx[4] = {0, 0, 2, -2};
char c[51][51];
bool f[51][51];

bool contain(int y, int x){
    return (0 <= y && y < h && 0 <= x && x < w);
}

signed main(){
    cin >> h >> w;
    cin >> sy >> sx >> gy >> gx;
    sy--; sx--; gy--; gx--;
    rep(i, 0, h){
        rep(j, 0, w){
            cin >> c[i][j];
            f[i][j] = false;
        }
    }
    queue<P> q;
    f[sy][sx] = true;
    q.push(P(sy, sx));
    while(q.size()){
        P p = q.front(); q.pop();
        int y = p.first, x = p.second;
        if(y == gy && x == gx) break;
        rep(i, 0, 4){
            int ny = y + dy[i];
            int nx = x + dx[i];
            if(contain(ny, nx) && f[ny][nx] == false){
                if(abs(c[y][x] - c[ny][nx]) <= 1){
                    f[ny][nx] = true;
                    q.push(P(ny, nx));
                }
            }
        }
        rep(i, 0, 4){
            int ny = y + hy[i];
            int nx = x + hx[i];
            int ty = y + dy[i];
            int tx = x + dx[i];
            if(contain(ny, nx) && f[ny][nx] == false){
                if(c[y][x] == c[ny][nx] && c[ty][tx] < c[y][x]){
                    f[ny][nx] = true;                    
                    q.push(P(ny, nx));
                }
            }
        }
    }
    cout << (f[gy][gx] ? "YES" : "NO") << endl;
}