H,W = map(int,input().split())
sy,sx,gy,gx = map(int,input().split())
sx,sy,gx,gy = sx - 1,sy-1,gx-1,gy-1
b = [input() for i in range(H)]
used = [[False for j in range(W)]for i in range(H)]
dx = [0,0,-1,1]
dy = [1,-1,0,0]
q = [(sy,sx)]
flag = False
while len(q) > 0:
	d = q.pop(0)
	if used[d[0]][d[1]]:
		continue
	used[d[0]][d[1]] = True
	if d[0] == gy and d[1] == gx:
		print('YES')
		flag = True
		break
	for i in range(4):
		nx = dx[i] + d[1]
		ny = dy[i] + d[0]
		if nx < 0 or ny < 0 or nx >= W or ny >= H:
			continue
		if b[ny][nx] == b[d[0]][d[1]]:
			q.append([ny,nx])
		if abs(int(b[ny][nx]) - int(b[d[0]][d[1]])) == 1:
			q.append([ny,nx])
	for i in range(4):
		nx = dx[i] + d[1]
		ny = dy[i] + d[0]
		nnx = dx[i] * 2 + d[1]
		nny = dy[i] * 2 + d[0]
		if nnx < 0 or nny < 0 or nnx >= W or nny >= H:
			continue
		if nx < 0 or ny < 0 or nx >= W or ny >= H:
			continue
		if b[nny][nnx] == b[d[0]][d[1]] and int(b[nny][nnx]) > int(b[ny][nx]):
			q.append([nny,nnx])
if not flag:
	print('NO')