#!usr/bin/env python # -*- coding:utf-8 -*- import numpy as np import math def move(sx,sy,b,gx,gy): flag[sx-1,sy-1] = 1 #print sx,sy if sx+1 <= h and flag[sx,sy-1] == 0: if math.fabs(b[sx-1,sy-1]-b[sx,sy-1]) <= 1: if sx+1 == gx and sy == gy: return 1 else: if move(sx+1,sy,b,gx,gy): return 1 if sx-1 > 0 and flag[sx-2,sy-1] == 0: if math.fabs(b[sx-1,sy-1]-b[sx-2,sy-1]) <= 1: if sx-1 == gx and sy == gy: return 1 else: if move(sx-1,sy,b,gx,gy): return 1 if sy+1 <= w and flag[sx-1,sy] == 0: if math.fabs(b[sx-1,sy-1]-b[sx-1,sy]) <= 1: if sy+1 == gy and sx == gx: return 1 else: if move(sx,sy+1,b,gx,gy): return 1 if sy-1 > 0 and flag[sx-1,sy-2] == 0: if math.fabs(b[sx-1,sy-1]-b[sx-1,sy-2]) <= 1: if sx == gx and sy-1 == gy: return 1 else: if move(sx,sy-1,b,gx,gy): return 1 if sx+2 <= h and flag[sx+1,sy-1] == 0: if b[sx-1,sy-1] == b[sx+1,sy-1] and b[sx-1,sy-1] > b[sx,sy-1]: if sx+2 == gx and sy == gy: return 1 else: if move(sx+2,sy,b,gx,gy): return 1 if sx-2 > 0 and flag[sx-3,sy-1] == 0: if b[sx-1,sy-1] == b[sx-3,sy-1] and b[sx-1,sy-1] > b[sx-2,sy-1]: if sx-2 == gx and sy == gy: return 1 else: if move(sx-2,sy,b,gx,gy): return 1 if sy+2 <= w and flag[sx-1,sy+1] == 0: if b[sx-1,sy-1] == b[sx-1,sy+1] and b[sx-1,sy-1] > b[sx-1,sy]: if sx == gx and sy+2 == gy: return 1 else: if move(sx,sy+2,b,gx,gy): return 1 if sy-2 > 0 and flag[sx-1,sy-3] == 0: if b[sx-1,sy-1] == b[sx-1,sy-3] and b[sx-1,sy-1] > b[sx-1,sy-2]: if sx == gx and sy-2 == gy: return 1 else: if move(sx,sy-2,b,gx,gy): return 1 return 0 if __name__ == '__main__': S = raw_input().split() h = int(S[0]) w = int(S[1]) SG = raw_input().split() sx = int(SG[0]) sy = int(SG[1]) gx = int(SG[2]) gy = int(SG[3]) b = np.zeros((h,w)) for i in range(h): B = raw_input() for j in range(w): b[i,j] = int(B[j]) #print b flag = np.zeros((h,w)) if move(sx,sy,b,gx,gy): print 'YES' else: print 'NO'