#!/usr/bin/env pypy3 # -*- coding: utf-8 -*- import collections State = collections.namedtuple("State", "size r c") class BreadthFirstSearch(object): def __init__(self, height, width, start, goal, stage): self.height = height self.width = width self.limit = 3200 self.start = start self.goal = goal self.stage = stage self.deltas = [(1, 0), (-1, 0), (0, 1), (0, -1)] self.possible = collections.defaultdict(bool) def judge(self): self.possible[self.start] = True q = collections.deque() q.append(self.start) while q: state0 = q.popleft() if state0 == self.goal: break for dr, dc in self.deltas: (r, c) = (state0.r + dr, state0.c + dc) if r < 0 or r >= self.height or c < 0 or c >= self.width: continue size = state0.size if self.stage[r][c] == "*": size += 1 else: size -= 1 if size <= 0 or size > self.limit: continue state = State(size, r, c) if self.possible[state]: continue self.possible[state] = True q.append(state) return self.possible[self.goal] def main(): height, width = map(int, input().split()) start = State(*map(int, input().split())) goal = State(*map(int, input().split())) stage = [input() for _ in range(height)] bfs = BreadthFirstSearch(height, width, start, goal, stage) print("Yes" if bfs.judge() else "No") if __name__ == '__main__': main()