def examine(x,y): if x < 0 or y < 0 or x >= width or y >= height: return False elif got[y][x] == 1: return False else: return True def path(x,y): got[y][x] = 1 value = targ[y][x] queue = [] for a,b in ([[x+1,y],[x-1,y],[x,y+1],[x,y-1]]): if examine(a,b) and (targ[b][a] == value - 1 or targ[b][a] == value + 1 or targ[b][a] == value): queue.append([a,b]) for c,d,e,f in ([[x+2,y,x+1,y],[x-2,y,x-1,y],[x,y+2,x,y+1],[x,y-2,x,y-1]]): if examine(c,d) and targ[d][c] == value and targ[f][e] < value: queue.append([c,d]) return queue height,width = (int(n) for n in input().split(' ')) iniy,inix,endy,endx = (int(n) - 1 for n in input().split(' ')) targ = [] for h in range(height): targ.append([int(n) for n in input()]) got = [[0 for w in range(width)] for h in range(height)] queue = [[inix,iniy]] while queue != []: #print(queue) nextqueue = [] for x,y in queue: temp = path(x,y) nextqueue.extend(temp) queue = nextqueue if got[endy][endx] == 0: print("NO") else: print("YES")