# coding: utf-8 # yukicoder My Practice # author: Leonardone @ NEETSDKASU def gis(): return map(int, raw_input().split()) def arr2d(h,w): return [[0] * w for _ in xrange(h)] def solve(): ansYes = "Yes" ansNo = "No" pCh = "*" mCh = "." (h,w) = gis() (a, si, sj) = start = gis() (b, gi, gj) = goal = gis() m = [raw_input() for _ in xrange(h)] l = abs(si - gi) + abs(sj - gj) if l % 2 == 0 and a % 2 != b % 2: print ansNo return if l % 2 == 1 and a % 2 == b % 2: print ansNo return minus = arr2d(h,w) plus = arr2d(h,w) def chk(rch2, c, y2, x2): if m[y2][x2] == pCh: if plus[y2][x2] == 0: rch2.append([c + 1, y2, x2]) plus[y2][x2] = 1 elif c > 1 and minus[y2][x2] < c - 1: rch2.append([c - 1, y2, x2]) minus[y2][x2] = c - 1 rch1 = [start] while len(rch1) > 0: rch2 = [] for (c,y,x) in rch1: if x > 0: chk(rch2, c, y, x - 1) if y > 0: chk(rch2, c, y - 1, x) if x + 1 < w: chk(rch2, c, y, x + 1) if y + 1 < h: chk(rch2, c, y + 1, x) rch1 = rch2 mcount = 0 for ml in m: mcount += ml.count(mCh) if mcount < 2 and a + l > b: print ansYes return gplus = False if m[gi][gj] == pCh: if gi > 0 and m[gi - 1][gj] == pCh: gplus = True if gj > 0 and m[gi][gj - 1] == pCh: gplus = True if gi + 1 < h and m[gi + 1][gj] == pCh: gplus = True if gj + 1 < w and m[gi][gj + 1] == pCh: gplus =True if gplus: print ansYes return if plus[gi][gj] > 0: print ansYes return flagP = False for i in xrange(h): for j in xrange(1,w): if plus[i][j] > 0 and plus[i][j - 1] > 0: flagP = True for j in xrange(w): for i in xrange(1,h): if plus[i][j] > 0 and plus[i - 1][j] > 0: flagP = True if flagP: if m[gi][gj] == pCh and gplus == False: print ansNo return print ansYes return if minus[gi][gj] > 0: print ansYes return print ansNo solve()