def read_data(): H, W = map(int, input().split()) A, Si, Sj = map(int, input().split()) B, Gi, Gj = map(int, input().split()) Ms = [[c == '*' for c in input()] for i in range(H)] return H, W, A, Si, Sj, B, Gi, Gj, Ms def solve(H, W, A, Si, Sj, B, Gi, Gj, Ms): if (A - B + (Si - Gi) + (Sj - Gj)) % 2: return False lower = [[float('inf')] * W for h in range(H)] upper = [[-1] * W for h in range(H)] lower[Si][Sj] = A upper[Si][Sj] = A fs = set([(Si, Sj)]) while fs: nfs = set() for i, j in fs: m = Ms[i][j] min_snow = lower[i][j] max_snow = upper[i][j] for di, dj in [(-1, 0), (1, 0), (0, -1), (0, 1)]: ni = i + di nj = j + dj if ni < 0 or ni >= H or nj < 0 or nj >= W: continue if update_status(m, min_snow, max_snow, ni, nj, upper, lower, Ms): nfs.add((ni, nj)) if lower[Gi][Gj] <= B and upper[Gi][Gj] >= B: return True fs = nfs return False def update_status(m, min_snow, max_snow, ni, nj, upper, lower, Ms): n_m = Ms[ni][nj] if m != n_m: n_min_snow = min_snow + 2 * n_m - 1 if n_min_snow == 0: n_min_snow = float('inf') n_max_snow = max_snow + 2 * n_m - 1 if n_max_snow == 0: n_max_snow = -1 elif n_m: n_min_snow = min_snow + 1 n_max_snow = float('inf') else: if min_snow == 1: n_min_snow = float('inf') elif min_snow % 2: n_min_snow = 2 else: n_min_snow = 1 n_max_snow = min_snow - 1 if n_max_snow == 0: n_max_snow = -1 changed = False if n_min_snow < lower[ni][nj]: lower[ni][nj] = n_min_snow changed = True if n_max_snow > upper[ni][nj]: upper[ni][nj] = n_max_snow changed = True return changed H, W, A, Si, Sj, B, Gi, Gj, Ms = read_data() if solve(H, W, A, Si, Sj, B, Gi, Gj, Ms): print('Yes') else: print('No')