import Queue h,w = map(int, raw_input().split()) sy,sx,gy,gx = map(int, raw_input().split()) sx-=1 sy-=1 gx-=1 gy-=1 dist = [[0,1], [0,-1], [1,0], [-1,0]] blocks = [[0]*w for _ in xrange(h)] checked = [[False]*w for _ in xrange(h)] for i in xrange(h): b = raw_input() for j in xrange(w): blocks[i][j] = int(b[j]) q = Queue.Queue() q.put([sx, sy]) checked[sx][sy] = True reach = False counter = 0 while q.qsize() > 0: counter += 1 pos = q.get() if pos[0]==gx and pos[1]==gy: reach = True break for d in dist: x = pos[0]+d[0] y = pos[1]+d[1] if x<0 or y<0 or h<=x or w<=y or checked[x][y]: continue if abs(blocks[pos[0]][pos[1]]-blocks[x][y]) <= 1 and checked[x][y]==False: q.put([x, y]) checked[x][y] = True for d in dist: x = pos[0]+d[0]*2 y = pos[1]+d[1]*2 if x<0 or y<0 or h<=x or w<=y or checked[x][y]: continue if blocks[pos[0]][pos[1]] >= blocks[x][y] and checked[x][y]==False: q.put([x, y]) checked[x][y] = True if reach: print "YES" else: print "NO"