You play a computer game. Your character stands on some level of a multilevel ice cave. In order to move on forward, you need to descend one level lower and the only way to do this is to fall through the ice.

The level of the cave where you are is a rectangular square grid of n rows and m columns. Each cell consists either from intact or from cracked ice. From each cell you can move to cells that are side-adjacent with yours (due to some limitations of the game engine you cannot make jumps on the same place, i.e. jump from a cell to itself). If you move to the cell with cracked ice, then your character falls down through it and if you move to the cell with intact ice, then the ice on this cell becomes cracked.

Let's number the rows with integers from 1 to n from top to bottom and the columns with integers from 1 to m from left to right. Let's denote a cell on the intersection of the r-th row and the c-th column as (r, c). 

You are staying in the cell (r_1, c_1) and this cell is cracked because you've just fallen here from a higher level. You need to fall down through the cell (r_2, c_2) since the exit to the next level is there. Can you do this?


-----Input-----

The first line contains two integers, n and m (1 ≤ n, m ≤ 500) — the number of rows and columns in the cave description.

Each of the next n lines describes the initial state of the level of the cave, each line consists of m characters "." (that is, intact ice) and "X" (cracked ice).

The next line contains two integers, r_1 and c_1 (1 ≤ r_1 ≤ n, 1 ≤ c_1 ≤ m) — your initial coordinates. It is guaranteed that the description of the cave contains character 'X' in cell (r_1, c_1), that is, the ice on the starting cell is initially cracked.

The next line contains two integers r_2 and c_2 (1 ≤ r_2 ≤ n, 1 ≤ c_2 ≤ m) — the coordinates of the cell through which you need to fall. The final cell may coincide with the starting one.


-----Output-----

If you can reach the destination, print 'YES', otherwise print 'NO'.


-----Examples-----
Input
4 6
X...XX
...XX.
.X..X.
......
1 6
2 2

Output
YES

Input
5 4
.X..
...X
X.X.
....
.XX.
5 3
1 1

Output
NO

Input
4 7
..X.XX.
.XX..X.
X...X..
X......
2 2
1 6

Output
YES



-----Note-----

In the first sample test one possible path is:

[Image]

After the first visit of cell (2, 2) the ice on it cracks and when you step there for the second time, your character falls through the ice as intended.

Difficulty: interview

Starter code:

Solutions:
def read_data():
    n, m = map(int, input().split())
    maze = [[False] * (m + 2)]
    for i in range(n):
        maze.append([False] + [c == '.' for c in input().rstrip()] + [False])
    maze.append([False] * (m + 2))
    r1, c1 = map(int, input().split())
    r2, c2 = map(int, input().split())
    return n, m, maze, r1, c1, r2, c2


def solve(n, m, maze, r1, c1, r2, c2):
    dots = count_surrounding_intact_ices(maze, r2, c2)
    if maze[r2][c2] == False:
        if r1 == r2 and c1 == c2:
            return dots >= 1
        else:
            return solve_wfs(n, m, maze, r1, c1, r2, c2)
    else:
        if dots >= 2:
            return solve_wfs(n, m, maze, r1, c1, r2, c2)
        if dots == 0:
            return False
        if dots == 1:
            return is_side_by_side(r1, c1, r2, c2)


def is_side_by_side(r1, c1, r2, c2):
    if r1 == r2:
        return abs(c1 - c2) == 1
    if c1 == c2:
        return abs(r1 - r2) == 1
    return False


def count_surrounding_intact_ices(maze, r, c):
    count = 0
    for rr, cc in [(r+1, c), (r-1, c), (r, c+1), (r, c-1)]:
        if maze[rr][cc]:
            count += 1
    return count

def solve_wfs(n, m, maze, r1, c1, r2, c2):
    frontier = [(r1, c1)]
    while frontier:
        new_frontier = []
        for r, c in frontier:
            for nr, nc in [(r+1, c), (r-1, c), (r, c+1), (r, c-1)]:
                if nr == r2 and nc == c2:
                    return True
                if not maze[nr][nc]:
                    continue
                maze[nr][nc] = False
                new_frontier.append((nr, nc))
        frontier = new_frontier
    return False

def __starting_point():
    n, m, maze, r1, c1, r2, c2 = read_data()
    if solve(n, m, maze, r1, c1, r2, c2):
        print('YES')
    else:
        print('NO')
__starting_point()

n, m = (int(x) for x in input().split())
mp = [[""]] * n
for i in range(n):
    mp[i] = list(input().strip())

x0, y0 = (int(x) for x in input().split())
x0 -= 1
y0 -= 1
x1, y1 = (int(x) for x in input().split())
x1 -= 1
y1 -= 1

def gen_neighbours(x, y):
    res = []
    if x > 0:
        res.append((x-1, y))
    if x < n - 1:
        res.append((x+1, y))
    if y > 0:
        res.append((x, y - 1))
    if y < m - 1:
        res.append((x, y + 1))
    return res

cnt = 0
for el in gen_neighbours(x1, y1):
    if mp[el[0]][el[1]] == '.' or el == (x0, y0):
        cnt += 1


if x0 == x1 and y0 == y1:
    if cnt > 0:
        print("YES")
    else:
        print("NO")
    return

if mp[x1][y1] == "." and cnt <= 1:
    print("NO")
    return

ind = 0
end = 1
q = [0] * (n * m * 2)
q[0] = (x0, y0)

while True:
    if ind == len(q) or q[ind] == 0:
        break

    x, y = q[ind]
    if (x, y) == (x1, y1):
        print("YES")
        return

    for el in gen_neighbours(x, y):
        if el == (x1, y1):
            print("YES")
            return

        if mp[el[0]][el[1]] == '.':
            q[end] = el
            end += 1
            mp[el[0]][el[1]] = 'X'
    ind += 1

print("NO")

#!/usr/bin/env python3
# -*- coding: utf-8 -*-

def test(x):
    if x == 'X' or type(x)== int:
        return False
    return True



(n, m) = ( int(i) for i in input().split())
map = []

for i in range(n):
    map.append([i for i in input()])

for i in map:
    while ' ' in i:
        i.remove(' ')


(r1, c1) = ( int(i) for i in input().split())
(r2, c2) = ( int(i) for i in input().split())

step = 0
map[r1-1][c1-1] = 0

if (map[r2-1][c2-1] == 'X'):
    flag = 0
    map[r2-1][c2-1] = '.'
else:
    flag = 1

now = [(r1-1, c1-1)]

while (type(map[r2-1][c2-1]) != int and now != []):
    now_new = []
    for (i, j) in now:
        if ( i > 0 ) :
            if test(map[i-1][j]) :
                map[i-1][j]= step+1
                now_new.append((i-1, j))
        if ( i < n-1 ) :
            if test(map[i+1][j]) :
                map[i+1][j]= step+1
                now_new.append((i+1, j))

        if ( j > 0  ) :
            if test(map[i][j-1]) :
                map[i][j-1]= step+1
                now_new.append((i, j-1))

        if ( j < m-1 ) :
            if test(map[i][j+1]) :
                map[i][j+1]= step+1
                now_new.append((i, j+1))

    now = now_new
    step = step + 1

if (type(map[r2-1][c2-1]) != int):
    print("NO")

else:
    if flag == 0:
        print("YES")
    else:
        acc = 0
        acc1 = 0
        i = r2-1
        j = c2-1

        if ( i > 0 ) :
            if type(map[i-1][j]) == int:
                acc1 +=1
            elif map[i-1][j] != 'X' :
                acc += 1

        if ( i < n-1 ) :
            if type(map[i+1][j]) == int:
                acc1 +=1
            elif map[i+1][j] != 'X' :
                acc += 1

        if ( j > 0  ) :
            if type(map[i][j-1]) == int :
                acc1 +=1
            elif map[i][j-1] != 'X' :
                acc += 1

        if ( j < m-1 ) :
            if type(map[i][j+1]) == int:
                acc1 +=1
            elif map[i][j+1] != 'X' :
                acc += 1



        if (acc == 0 and acc1 < 2):
            print("NO")
        else:
            print("YES")


def read_data():
    n, m = map(int, input().split())
    maze = [[False] * (m + 2)]
    for i in range(n):
        maze.append([False] + [c == '.' for c in input().rstrip()] + [False])
    maze.append([False] * (m + 2))
    r1, c1 = map(int, input().split())
    r2, c2 = map(int, input().split())
    return n, m, maze, r1, c1, r2, c2


def solve(n, m, maze, r1, c1, r2, c2):
    dots = count_surrounding_intact_ices(maze, r2, c2)
    if maze[r2][c2] == False:
        if r1 == r2 and c1 == c2:
            return dots >= 1
        else:
            return solve_wfs(n, m, maze, r1, c1, r2, c2)
    else:
        if dots >= 2:
            return solve_wfs(n, m, maze, r1, c1, r2, c2)
        if dots == 0:
            return False
        if dots == 1:
            return is_side_by_side(r1, c1, r2, c2)


def is_side_by_side(r1, c1, r2, c2):
    if r1 == r2:
        return abs(c1 - c2) == 1
    if c1 == c2:
        return abs(r1 - r2) == 1
    return False


def count_surrounding_intact_ices(maze, r, c):
    count = 0
    for rr, cc in [(r+1, c), (r-1, c), (r, c+1), (r, c-1)]:
        if maze[rr][cc]:
            count += 1
    return count

def solve_wfs(n, m, maze, r1, c1, r2, c2):
    frontier = [(r1, c1)]
    while frontier:
        new_frontier = []
        for r, c in frontier:
            for nr, nc in [(r+1, c), (r-1, c), (r, c+1), (r, c-1)]:
                if nr == r2 and nc == c2:
                    return True
                if not maze[nr][nc]:
                    continue
                maze[nr][nc] = False
                new_frontier.append((nr, nc))
        frontier = new_frontier
    return False

def __starting_point():
    n, m, maze, r1, c1, r2, c2 = read_data()
    if solve(n, m, maze, r1, c1, r2, c2):
        print('YES')
    else:
        print('NO')
__starting_point()

#file = open('test.txt', 'r')
def recurse():
	nonlocal ans
	qu = []
	qu.append((r1, c1))
	count = 1
	i = 0
	while i < count:
		r, c = qu[i]
		if r == r2 and c == c2:
			ans = True
			return
		
		mas[r][c] = 1
			
		if mas[r + 1][c] == 0:
			#recurse(r + 1, c)
			qu.append((r + 1, c))
			mas[r + 1][c] = 1
			count += 1
		if mas[r - 1][c] == 0:
			#recurse(r - 1, c)
			qu.append((r - 1, c))
			mas[r - 1][c] = 1
			count += 1
		if mas[r][c + 1] == 0:
			#recurse(r, c + 1)
			qu.append((r, c + 1))
			mas[r][c + 1] = 1
			count += 1
		if mas[r][c - 1] == 0:
			#recurse(r, c - 1)
			qu.append((r, c - 1))
			mas[r][c - 1] = 1
			count += 1
		i += 1

n, m = [int(x) for x in input().split()]
#n, m = [int(x) for x in file.readline().split()]
mas = []
mas.append([-1] * (m + 2))
for i in range(1, n + 1):
	mas.append([0] * (m + 2))
mas.append([-1] * (m + 2))

for i in range(1, n + 1):
	mas[i][0] = mas[i][m + 1] = -1

for i in range(1, n + 1):	
	s = input()
	#s = file.readline()
	for j in range(1, m + 1):
		if s[j - 1] == 'X':
			mas[i][j] = -1

r1, c1 = [int(x) for x in input().split()]
r2, c2 = [int(x) for x in input().split()]
#r1, c1 = [int(x) for x in file.readline().split()]
#r2, c2 = [int(x) for x in file.readline().split()]

her = 0
if mas[r2 - 1][c2] != -1:
	her += 1
if mas[r2 + 1][c2] != -1:
	her += 1
if mas[r2][c2 - 1] != -1:
	her += 1
if mas[r2][c2 + 1] != -1:
	her += 1
if r1 == r2 and c1 == c2:
	if her > 0:
		print("YES")
	else:
		print("NO")
elif abs(r1 - r2) + abs(c1 - c2) == 1:
	if mas[r2][c2] != 0 or her > 0:
		print("YES")
	else:
		print("NO")
else:
	ans = False
	z = mas[r2][c2]
	mas[r1][c1] = mas[r2][c2] = 0
	recurse()
	#mas[r2][c2] = z
	if not ans:
		print("NO")
	elif z != 0:
		print("YES")
	else:
		if her > 1:
			print("YES")
		else:
			print("NO")

row, col = (int(x) for x in input().split())

matrix = [['X' for i in range(col + 2)]]
for _ in range(row):
	matrix.append(['X'] + [str(x) for x in input()] + ['X'])
matrix.append(['X' for i in range(col + 2)])

startR, startC = (int(x) for x in input().split())
endR, endC = (int(x) for x in input().split())

def search_way(matrix, startR, startC, endR, endC):
	countToEnd = 0
	dx = [0, 0, -1, 1]
	dy = [1, -1, 0, 0]
	for i in range(len(dx)):
		if matrix[endR + dx[i]][endC + dy[i]] == '.':
			countToEnd += 1
	if endR == startR and endC == startC:
		if matrix[endR][endC] == 'X' and countToEnd < 1:
			return "NO"
		elif matrix[endR][endC] == 'X':
			return "YES"
	
	if countToEnd < 2 and matrix[endR][endC] == '.':
		# print("Count To End!!")
		if countToEnd == 1 and abs(endR - startR) + abs(endC - startC) == 1:
			return "YES"
		return "NO"
	matrix[endR][endC] = '.'
	queue = [(startR, startC),]
	while len(queue) >= 1:
		curValue = queue.pop(-1)
		if curValue[0] == endR and curValue[1] == endC:
			return "YES"
		# print(curValue)
		for i in range(len(dx)):
			if matrix[curValue[0] + dx[i]][curValue[1] + dy[i]] == '.':
				matrix[curValue[0] + dx[i]][curValue[1] + dy[i]] = 'X'
				queue.append((curValue[0] + dx[i], curValue[1] + dy[i]))
	# for i in range(len(matrix)):
	# 	print(matrix[i])
	return "NO"

print(search_way(matrix, startR, startC, endR, endC))

def isConnected(r1, c1, r2, c2, board) :
    visited = [[0]*c for i in range(r)]
    Q = [[r1, c1]]
    visited[r1][c1] = 1
    while Q :
        q = Q.pop(0)
        x,y = q[0],q[1]
        for i in range(4) :
            new_x = x+dx[i]
            new_y = y+dy[i]
            if 0<= new_x < r and 0<= new_y < c and visited[new_x][new_y] == 0 and board[new_x][new_y] == '.' :
                visited[new_x][new_y] = 1
                Q.append([new_x, new_y])
                if new_x == r2 and new_y == c2 : return True
    return False

dx = [-1, 0, 0, 1]
dy = [0, -1, 1, 0]

r,c = list(map(int, input().split()))
board = [list(input()) for i in range(r)]
r1, c1 = list(map(int, input().split()))
r2, c2 = list(map(int, input().split()))
r1-=1;c1-=1;r2-=1;c2-=1
isX = board[r2][c2] == 'X'
G = []

for i in range(4) :
    x = r2 + dx[i]
    y = c2 + dy[i]
    if x >=0 and x < r and y >= 0 and y < c and board[x][y] == '.' :
        G.append([x,y])
if abs(r1-r2) + abs(c1-c2) == 1 :
    if board[r2][c2] == 'X' :
        print("YES")
    else :
        if len(G) > 0 :
            print("YES")
        else :
            print("NO")
elif r1 == r2 and c1 == c2 :
    if len(G) == 0 :
        print("NO")
    else :
        print("YES")
elif len(G) == 0 :
    print("NO")
else :
    if board[r2][c2] == 'X' :
        board[r2][c2] = '.'
        if isConnected(r1, c1, r2, c2, board) :
            print("YES")
        else :
            print("NO")
    else :
        if len(G) < 2 :
            print("NO")
        else :
            if isConnected(r1, c1, r2, c2, board) :
                print("YES")
            else :
                print("NO")


def pick(D, v):
	return D[v[0]][v[1]]


def getNeighbours(A, x, y, t='.'):
	neighbours = []
	if x > 0 and A[x-1][y] == t:
		neighbours.append((x-1, y))
	if y > 0 and A[x][y-1] == t:
		neighbours.append((x, y-1))
	if x < len(A)-1 and A[x+1][y] == t:
		neighbours.append((x+1, y))
	if y < len(A[0])-1 and A[x][y+1] == t:
		neighbours.append((x, y+1))
	return neighbours


def countNeighbours(A, x, y, t='.'):
	return len(getNeighbours(A, x, y, t))


def hasPath(A, xs, ys, xe, ye):
	# Pre-set end-location 'dot'
	A[xe][ye] = '.'

	D = [[-1 for _ in range(len(A[0]))] for _ in range(len(A))]
	D[xs][ys] = 0
	Q = [(xs, ys)]

	# BFS
	while len(Q) > 0:
		u = Q.pop()
		for v in getNeighbours(A, *u):
			if pick(D, v) == -1:
				Q.insert(0, v)
				D[v[0]][v[1]] = pick(D, u) + 1

	return D[xe][ye] != -1


def solve(A, r1, c1, r2, c2):
	if r1 == r2 and c1 == c2:
		if countNeighbours(A, r1, c1) > 0:
			return True
		else:
			return False
	elif (r2, c2) in getNeighbours(A, r1, c1) or (r2, c2) in getNeighbours(A, r1, c1, 'X'):
		if A[r2][c2] == 'X':
			return True
		else:
			if countNeighbours(A, r2, c2) > 0:
				return True
			else:
				return False
	elif A[r2][c2] == '.':
		if countNeighbours(A, r2, c2) >= 2 and hasPath(A, r1, c1, r2, c2):
			return True
		else:
			return False
	elif A[r2][c2] == 'X':
		if countNeighbours(A, r2, c2) > 0 and hasPath(A, r1, c1, r2, c2):
			return True
		else:
			return False


def main():
	n, m = list(map(int, input().split()))
	A = [list(input()) for _ in range(n)]
	r1, c1 = [int(w)-1 for w in input().split()]
	r2, c2 = [int(w)-1 for w in input().split()]

	ans = solve(A, r1, c1, r2, c2)
	print('YES' if ans else 'NO')

main()


def pick(D, v):
	return D[v[0]][v[1]]


def getNeighbours(A, x, y, t='.'):
	neighbours = []
	if x > 0 and A[x-1][y] == t:
		neighbours.append((x-1, y))
	if y > 0 and A[x][y-1] == t:
		neighbours.append((x, y-1))
	if x < len(A)-1 and A[x+1][y] == t:
		neighbours.append((x+1, y))
	if y < len(A[0])-1 and A[x][y+1] == t:
		neighbours.append((x, y+1))
	return neighbours


def countNeighbours(A, x, y, t='.'):
	return len(getNeighbours(A, x, y, t))


def hasPath(A, xs, ys, xe, ye):
	# Pre-set end-location 'dot'
	A[xe][ye] = '.'

	D = [[-1 for _ in range(len(A[0]))] for _ in range(len(A))]
	D[xs][ys] = 0
	Q = [(xs, ys)]

	# BFS
	while len(Q) > 0:
		u = Q.pop()
		for v in getNeighbours(A, *u):
			if pick(D, v) == -1:
				Q.insert(0, v)
				D[v[0]][v[1]] = pick(D, u) + 1

	return D[xe][ye] != -1


def solve(A, r1, c1, r2, c2):
	if r1 == r2 and c1 == c2:
		if countNeighbours(A, r1, c1) > 0:
			return True
		else:
			return False
	elif (r2, c2) in getNeighbours(A, r1, c1) or (r2, c2) in getNeighbours(A, r1, c1, 'X'):
		if A[r2][c2] == 'X':
			return True
		else:
			if countNeighbours(A, r2, c2) > 0:
				return True
			else:
				return False
	elif A[r2][c2] == '.':
		if countNeighbours(A, r2, c2) >= 2 and hasPath(A, r1, c1, r2, c2):
			return True
		else:
			return False
	elif A[r2][c2] == 'X':
		if countNeighbours(A, r2, c2) > 0 and hasPath(A, r1, c1, r2, c2):
			return True
		else:
			return False


def main():
	n, m = list(map(int, input().split()))
	A = [list(input()) for _ in range(n)]
	r1, c1 = [int(w)-1 for w in input().split()]
	r2, c2 = [int(w)-1 for w in input().split()]

	ans = solve(A, r1, c1, r2, c2)
	print('YES' if ans else 'NO')

main()


# -*- coding: utf-8 -*-

"""
created by huash06 at 2015-05-18 23:20


"""

__author__ = 'huash06'

import sys
import os
import itertools
import collections
import functools
import bisect
import datetime



DELTA = [(1, 0 ), (-1, 0), (0, -1), (0, 1)]

def existsPath(board, sr, sc, er, ec):
    visited = {(sr, sc)}
    q = [(sr, sc)]
    while q:
        r, c = q.pop(0)

        for d in DELTA:
            nr = r + d[0]
            nc = c + d[1]
            if nr == er and nc == ec:
                return True
            if 0 <= nr < N and 0 <= nc < M and (nr, nc) not in visited and board[nr][nc] == '.':
                visited.add((nr, nc))
                q.append((nr, nc))

    return False

def isNeighbor(sr, sc, er, ec):
    for d in DELTA:
        r = sr + d[0]
        c = sc + d[1]
        if r == er and c == ec:
            return True
    return False

N, M = list(map(int, input().split()))

board = []
for i in range(N):
    board.append([x for x in input()])

sr, sc = list(map(int, input().split()))
er, ec = list(map(int, input().split()))

sr -= 1
sc -= 1
er -= 1
ec -= 1


if board[er][ec] == 'X':
    if existsPath(board, sr, sc, er, ec):
        print('YES')
    else:
        print('NO')
else:
    itactNeighbor = 0
    for d in DELTA:
        r = er + d[0]
        c = ec + d[1]
        if 0 <= r < N and 0 <= c < M and board[r][c] == '.':
            itactNeighbor += 1

    if itactNeighbor > 1:
        if existsPath(board, sr, sc, er, ec):
            print('YES')
        else:
            print('NO')
    else:
        if itactNeighbor == 1 and isNeighbor(sr, sc, er, ec):
            print('YES')
        else:
            print('NO')





n,m=[int(x) for x in input().split()]
inp=[input() for i in range(n)]
source=[int(x)-1 for x in input().split()]
dest=[int(x)-1 for x in input().split()]

def valid(x):
	return True if 0<=x[0]<n and 0<=x[1]<m and inp[x[0]][x[1]]=='.' else False

def getn(x):
	toret=[]
	y=(x[0]-1,x[1])
	if valid(y):
		toret.append(y)
	y=(x[0]+1,x[1])
	if valid(y):
		toret.append(y)
	y=(x[0],x[1]-1)
	if valid(y):
		toret.append(y)
	y=(x[0],x[1]+1)
	if valid(y):
		toret.append(y)
	return toret

if source==dest:
	print('YES' if len(getn(dest)) else 'NO')
else:
	dat=False
	dis=0
	if inp[dest[0]][dest[1]]=='X':
		inp[dest[0]]=inp[dest[0]][:dest[1]]+'.'+inp[dest[0]][dest[1]+1:]
		dat=True
	if tuple(dest) in getn(source):
		dis=1
	vis=[[False]*m for i in range(n)]
	mystak=[source]
	while mystak!=[]:
		x=mystak.pop()
		if vis[x[0]][x[1]]:
			continue
		vis[x[0]][x[1]]=True
		for i in getn(x):
			mystak.append(i)
#	for i in vis:
#		print(i)
	print('YES' if vis[dest[0]][dest[1]] and (len(getn(dest))>1-dis or dat) else 'NO')


n,m=[int(x) for x in input().split()]
inp=[input() for i in range(n)]
source=[int(x)-1 for x in input().split()]
dest=[int(x)-1 for x in input().split()]

def valid(x):
	return True if 0<=x[0]<n and 0<=x[1]<m and inp[x[0]][x[1]]=='.' else False

def getn(x):
	toret=[]
	y=(x[0]-1,x[1])
	if valid(y):
		toret.append(y)
	y=(x[0]+1,x[1])
	if valid(y):
		toret.append(y)
	y=(x[0],x[1]-1)
	if valid(y):
		toret.append(y)
	y=(x[0],x[1]+1)
	if valid(y):
		toret.append(y)
	return toret

if source==dest:
	print('YES' if len(getn(dest)) else 'NO')
else:
	dat=False
	dis=0
	if inp[dest[0]][dest[1]]=='X':
		inp[dest[0]]=inp[dest[0]][:dest[1]]+'.'+inp[dest[0]][dest[1]+1:]
		dat=True
	if tuple(dest) in getn(source):
		dis=1
	vis=[[False]*m for i in range(n)]
	mystak=[source]
	while mystak!=[]:
		x=mystak.pop()
		if vis[x[0]][x[1]]:
			continue
		vis[x[0]][x[1]]=True
		for i in getn(x):
			mystak.append(i)
#	for i in vis:
#		print(i)
	print('YES' if vis[dest[0]][dest[1]] and (len(getn(dest))>1-dis or dat) else 'NO')


import sys
sys.setrecursionlimit(1000000000)

def bfs(x, y):
    q = [(y, x)]
    
    while q:
        x = q[0][1]
        y = q[0][0]
        q.pop(0)
        if (x-1 > -1) and (g[y][x-1] == '.'):
            g[y][x-1] = 'X'
            q.append((y, x-1))
        if (x+1 < m) and (g[y][x+1] == '.'):
            g[y][x+1] = 'X'
            q.append((y, x+1))
        if (y-1 > -1) and (g[y-1][x] == '.'):
            g[y-1][x] = 'X'
            q.append((y-1, x))
        if (y+1 < n) and (g[y+1][x] == '.'):
            g[y+1][x] = 'X'
            q.append((y+1, x))
            
            
n, m = map(int, input().split())
g = [['']*m for i in range(n)]
for i in range(n):
    t = input()
    for j in range(m):
        g[i][j] = t[j]

y, x = map(int, input().split())
b, a = map(int, input().split())
x -= 1
y -= 1
a -= 1
b -= 1
    
if (x == a) and (y == b):  # если начало и конец пути совпадают
    if ((x-1 > -1) and (g[y][x-1] == '.')) or ((x+1 < m) and (g[y][x+1] == '.')) or ((y-1 > -1) and (g[y-1][x] == '.')) or ((y+1 < n) and (g[y+1][x] == '.')):
        print('YES')
    else:
        print('NO')
        
else:  # если финишная клетка треснувшая или у нее есть целые соседи
    f = False
    if g[b][a] == '.':
        f = True
        
    one = (a-1 > -1) and (g[b][a-1] == '.')
    two = (a+1 < m) and (g[b][a+1] == '.')
    three = (b-1 > -1) and (g[b-1][a] == '.')
    four = (b+1 < n) and (g[b+1][a] == '.')

    g[b][a] = '.'
    bfs(x, y)
    
    if g[b][a] == 'X':
        if f:
            if one+two+three+four > 1:
                print('YES')
            elif (((a == x-1) and (b == y)) or ((a == x+1) and (b == y)) or ((a == x) and (b == y-1)) or ((a == x) and (b == y+1))) and (one+two+three+four == 1):
                print('YES')
            else:
                print('NO')
        else:
            print('YES')
    else:
        print('NO')

from collections import deque
ds = ((1, 0), (0, 1), (-1, 0), (0, -1))
n, m = list(map(int, input().split()))
a = [list(input()) for _ in range(n)]
si, sj = tuple(map(int, input().split()))
ti, tj = tuple(map(int, input().split()))
si -= 1
sj -= 1
ti -= 1
tj -= 1

def count_ok(i, j):
    r = 0
    for di, dj in ds:
        ni, nj = i + di, j + dj
        if (0 <= ni < n and 0 <= nj < m and a[ni][nj] != 'X') \
           or (ni, nj) == (si, sj):
            r += 1
    return r

if (si, sj) == (ti, tj):
    print('YES' if count_ok(si, sj) >= 1 else 'NO')
    return

c = a[ti][tj]
a[ti][tj] = '.'
used = set()
q = deque()
used.add((si, sj))
q.append((si, sj))
while q:
    i, j = q.popleft()
    for di, dj in ds:
        ni, nj = i + di, j + dj
        if 0 <= ni  < n and 0 <= nj < m and\
           a[ni][nj] != 'X' and (ni, nj) not in used:
            used.add((ni, nj))
            q.append((ni, nj))
if (ti, tj) not in used:
    print('NO')
else:
    if c == 'X':
        print('YES')
    else:
        print('YES' if count_ok(ti, tj) >= 2 else 'NO')

          
        


n,m = map(int, input().split())
a = []
for i in range(n):
    a.append([])
for i in range(n):
    c = input()
    for j in c:
        if (j == '.'):
            a[i].append(0)
        else:
            a[i].append(1)
x1,y1 = map(int,input().split())
x2,y2 = map(int,input().split())
x1 -= 1
y1 -= 1
x2 -= 1
y2 -= 1
a[x1][y1] = 0
f = []
qs = 0
qt = 1
f.append([x1,y1])
while (qs < qt):
    x = f[qs][0]
    y = f[qs][1]
    if ([x,y] == [x2,y2]):
        break
    a[x][y] = 1
    qs += 1
    if (x < n-1 and (a[x+1][y] == 0 or [x+1,y] == [x2,y2])):
        qt += 1
        f.append([x+1,y])
        if ([x+1,y] == [x2,y2]):
            break;
        a[x+1][y] += 2
    if (x > 0 and (a[x-1][y] == 0 or [x-1,y] == [x2,y2])):
        qt += 1
        f.append([x-1,y])
        if ([x-1,y] == [x2,y2]):
            break;
        a[x-1][y] += 2
    if (y < m-1 and (a[x][y+1] == 0 or [x,y+1] == [x2,y2])):
        qt += 1
        f.append([x,y+1])
        if ([x,y+1] == [x2,y2]):
            break;
        a[x][y+1] += 2
    if (y > 0 and (a[x][y-1] == 0 or [x,y-1] == [x2,y2])):
        qt += 1
        f.append([x,y-1])
        if ([x,y-1] == [x2,y2]):
            break;
        a[x][y-1] += 2
else:
    print('NO')
    return
if (a[x2][y2] == 1):
    print('YES')
else:
    #print(a[x2-1][y2],a[x2][y2-1])
    if (x2 > 0 and a[x2-1][y2] != 1):
        print('YES')
    elif (x2 < n-1 and a[x2+1][y2] != 1):
        print('YES')
    elif (y2 < m-1 and a[x2][y2+1] != 1):
        print('YES')
    elif (y2 > 0 and a[x2][y2-1] != 1):
        print('YES')
    else:
        print('NO')

import heapq
from copy import deepcopy
dir = [(-1, 0), (0, 1), (1, 0), (0, -1)]

def decr(x): return x - 1

H, W = list(map(int, input().split()))
l = [list(input()) for i in range(H)]
si, sj = list(map(decr, list(map(int, input().split()))))
gi, gj = list(map(decr, list(map(int, input().split()))))

que = []
heapq.heappush(que, (si, sj))
res = False
while len(que):
    i, j = heapq.heappop(que)
    for k in range(4):
        ni = i + dir[k][0]
        nj = j + dir[k][1]
        if ni == gi and nj == gj and l[ni][nj] == 'X':
            res = True
        if 0 <= ni < H and 0 <= nj < W and l[ni][nj] == '.':
            l[ni][nj] = 'X'
            heapq.heappush(que, (ni, nj))


if res:
    print("YES")
else:
    print("NO")


3
from collections import deque
def dfs ():
  while(len(queue)!=0):
    s=queue.popleft()
    (i,j)=s
    for (ni,nj) in [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]:      
      if ni in range(0,n) and nj in range(0,m):
        fl=data[ni][nj]
        if(e == (ni,nj)) and fl=="X":
          return True
        elif fl == ".":
          data[ni][nj] = "X"
          queue.append((ni,nj))
  return False
[n,m]=list(map(int,(input().split())))
data=list()
for i in range(0,n):
  data.append(list([x for x in input()]))
[si,sj]=list(map(int,(input().split())))
[ei,ej]=list(map(int,(input().split())))
e=(ei-1,ej-1)
queue=deque()
queue.append((si-1,sj-1))
print("YES" if dfs() else "NO")  


3
from collections import deque
from array import array
def dfs ():
  while(len(queue)!=0):
    s=queue.popleft()
    (i,j)=s
    for (ni,nj) in [(i-1,j),(i+1,j),(i,j-1),(i,j+1)]:      
      if ni in range(0,n) and nj in range(0,m):
        c=ni*m+nj
        fl=data[c]
        if(e == (ni,nj)) and fl==1:
          return True
        elif fl == 0:
          data[c] = 1
          queue.append((ni,nj))
  return False
[n,m]=list(map(int,(input().split())))
data=array('B')
for i in range(0,n):
  data.extend([0 if x=='.' else 1 for x in input()])
[si,sj]=list(map(int,(input().split())))
[ei,ej]=list(map(int,(input().split())))
e=(ei-1,ej-1)
queue=deque()
queue.append((si-1,sj-1))
print("YES" if dfs() else "NO")  


n, m = [int(x) for x in input().split()]
visited = [[True for i in range(m+2)]]
visited += [[True]+[False if c == '.' else True for c in input()]+[True] for i in range(n)]
visited += [[True for i in range(m+2)]]
start = tuple(int(x) for x in input().split())
finish = tuple(int(x) for x in input().split())
visited[start[0]][start[1]] = False

def neighbours(p):
    return ((p[0]+1,p[1]), (p[0],p[1]+1), (p[0]-1,p[1]), (p[0],p[1]-1))
gates = [p for p in neighbours(finish) if not visited[p[0]][p[1]]]

def DFS(p, gates):
    stack = [p]
    while stack:
        node = stack.pop()
        if node in gates: return True
        x,y = node
        if visited[x][y]: continue
        visited[x][y] = True
        stack.extend(neighbours(node))
    return False

if finish == start and len(gates) > 0:
    print('YES')
elif not visited[finish[0]][finish[1]] and len(gates) < 2 or len(gates) == 0:
    print('NO')
else:
    print('YES' if DFS(start, gates) else 'NO')




def main():
    n, m = list(map(int, input().split()))
    nm = n * m
    neigh = [[] for _ in range(nm)]
    for i in range(0, nm - m, m):
        for j in range(i, i + m):
            neigh[j].append(j + m)
            neigh[j + m].append(j)
    for i in range(0, nm, m):
        for j in range(i, i + m - 1):
            neigh[j].append(j + 1)
            neigh[j + 1].append(j)
    field = [c == '.' for _ in range(n) for c in input()]
    l = []
    for _ in (0, 1):
        i, j = list(map(int, input().split()))
        l.append(i * m + j - m - 1)
    start, stop = l
    if start == stop:
        print(("NO", "YES")[any(field[_] for _ in neigh[stop])])
        return
    field[start] = True
    if field[stop] and sum(field[_] for _ in neigh[stop]) < 2:
        print("NO")
        return
    nxt, field[stop] = (start,), True
    while nxt:
        cur, nxt = nxt, []
        for u in cur:
            if u == stop:
                print("YES")
                return
            for v in neigh[u]:
                if field[v]:
                    field[v] = False
                    nxt.append(v)
    print("NO")


def __starting_point():
    main()

__starting_point()

def main():
    n, m = list(map(int, input().split()))
    nm = n * m
    neigh = [[] for _ in range(nm)]
    for i in range(0, nm - m, m):
        for j in range(i, i + m):
            neigh[j].append(j + m)
            neigh[j + m].append(j)
    for i in range(0, nm, m):
        for j in range(i, i + m - 1):
            neigh[j].append(j + 1)
            neigh[j + 1].append(j)
    field = [c == '.' for _ in range(n) for c in input()]
    l = []
    for _ in (0, 1):
        i, j = list(map(int, input().split()))
        l.append(i * m + j - m - 1)
    start, stop = l
    if start == stop:
        print(("NO", "YES")[any(field[_] for _ in neigh[stop])])
        return
    field[start] = True
    if field[stop] and sum(field[_] for _ in neigh[stop]) < 2:
        print("NO")
        return
    nxt, field[stop] = (start,), True
    while nxt:
        cur, nxt = nxt, set()
        for u in cur:
            if u == stop:
                print("YES")
                return
            for v in neigh[u]:
                if field[v]:
                    field[v] = False
                    nxt.add(v)
    print("NO")


def __starting_point():
    main()

__starting_point()

from http.cookiejar import reach

def is_path_exist( cage,visited,i1, j1, i2, j2):
    dx=[0,0,-1,1]
    dy=[-1,1,0,0]
    temp_point=[]
    reached=False
    stk_adj=[]
    stk_adj.append([i1,j1])
    cage[i1][j1]='X'
    while(len(stk_adj) and not reached):
        temp_point=stk_adj.pop()
        for i in range(0,4):
            if ((temp_point[0] + dx[i] > -1 and temp_point[0] + dx[i] < len(cage))
                and (temp_point[1] + dy[i] > -1 and temp_point[1] + dy[i] < len(cage[0]))
                and visited[temp_point[0] + dx[i]][temp_point[1] + dy[i]] == False):
                    if (temp_point[0] + dx[i] == i2 and temp_point[1] + dy[i] == j2):
                        reached=True
                        break
                    if (cage[temp_point[0] + dx[i]][temp_point[1] + dy[i]] != 'X'):
                        visited[temp_point[0] + dx[i]][temp_point[1] + dy[i]] = True;
                        stk_adj.append([temp_point[0]+dx[i],temp_point[1]+dy[i]])
    return reached

dx=[0,0,-1,1]
dy=[-1,1,0,0]
numbers = list(map(int, input().split()))
n=int(numbers[0])
m=int(numbers[1])
temp_line=""
cage=[]
visited=[[False for x in range(m)]for y in range(n)]
for i in range(0,n):
    cage.append([])
    temp_line=input()
    for j in range(0,m):
        cage[i].append(temp_line[j])
numbers = list(map(int, input().split()))
i1=int(numbers[0]-1)
j1=int(numbers[1]-1)
numbers = list(map(int, input().split()))
i2=int(numbers[0]-1)
j2=int(numbers[1]-1)
pos=0
if(is_path_exist(cage, visited, i1, j1, i2, j2)):
    if(cage[i2][j2]=='X'):
        print('YES')
        pos=1
    if(pos==0):
        count=0
        for i in range(0,4):
            if (i2 + dx[i] > -1 and i2 + dx[i] < len(cage) and j2 + dy[i] > -1 and j2 + dy[i] < len(cage[0])
                        and (cage[i2 + dx[i]][j2 + dy[i]] == '.' or (i2 + dx[i] == i1 and j2 + dy[i] == j1)) ):
                count+=1
        if(count>1):
            print('YES')
        else:
            print('NO')
else:
    print('NO')







def is_path_exist( cage,visited,i1, j1, i2, j2):
    dx=[0,0,-1,1]
    dy=[-1,1,0,0]
    temp_point=[]
    reached=False
    stk_adj=[]
    stk_adj.append([i1,j1])
    cage[i1][j1]='X'
    while(len(stk_adj) and not reached):
        temp_point=stk_adj.pop()
        for i in range(0,4):
            if ((temp_point[0] + dx[i] > -1 and temp_point[0] + dx[i] < len(cage))
                and (temp_point[1] + dy[i] > -1 and temp_point[1] + dy[i] < len(cage[0]))
                and visited[temp_point[0] + dx[i]][temp_point[1] + dy[i]] == False):
                    if (temp_point[0] + dx[i] == i2 and temp_point[1] + dy[i] == j2):
                        reached=True
                        break
                    if (cage[temp_point[0] + dx[i]][temp_point[1] + dy[i]] != 'X'):
                        visited[temp_point[0] + dx[i]][temp_point[1] + dy[i]] = True;
                        stk_adj.append([temp_point[0]+dx[i],temp_point[1]+dy[i]])
    return reached

dx=[0,0,-1,1]
dy=[-1,1,0,0]
numbers = list(map(int, input().split()))
n=int(numbers[0])
m=int(numbers[1])
temp_line=""
cage=[]

visited=[[False]*m for _ in range(n) ]
for i in range(0,n):
    cage.append([])
    temp_line=input()
    for j in range(0,m):
        cage[i].append(temp_line[j])
numbers = list(map(int, input().split()))
i1=int(numbers[0]-1)
j1=int(numbers[1]-1)
numbers = list(map(int, input().split()))
i2=int(numbers[0]-1)
j2=int(numbers[1]-1)
pos=0
if(is_path_exist(cage, visited, i1, j1, i2, j2)):
    if(cage[i2][j2]=='X'):
        print('YES')
        pos=1
    if(pos==0):
        count=0
        for i in range(0,4):
            if (i2 + dx[i] > -1 and i2 + dx[i] < len(cage) and j2 + dy[i] > -1 and j2 + dy[i] < len(cage[0])
                        and (cage[i2 + dx[i]][j2 + dy[i]] == '.' or (i2 + dx[i] == i1 and j2 + dy[i] == j1)) ):
                count+=1
        if(count>1):
            print('YES')
        else:
            print('NO')
else:
    print('NO')






from http.cookiejar import reach
#import numpy
def is_path_exist( cage,visited,i1, j1, i2, j2):
    dx=[0,0,-1,1]
    dy=[-1,1,0,0]
    temp_point=[]
    reached=False
    stk_adj=[]
    stk_adj.append([i1,j1])
    #cage[i1][j1]='X'
    while(len(stk_adj) and not reached):
        temp_point=stk_adj.pop()
        for i in range(0,4):
            if ((temp_point[0] + dx[i] > -1 and temp_point[0] + dx[i] < len(cage))
                and (temp_point[1] + dy[i] > -1 and temp_point[1] + dy[i] < len(cage[0]))
                and visited[temp_point[0] + dx[i]][temp_point[1] + dy[i]] == False):
                    if (temp_point[0] + dx[i] == i2 and temp_point[1] + dy[i] == j2):
                        reached=True
                        break
                    if (cage[temp_point[0] + dx[i]][temp_point[1] + dy[i]] != 'X'):
                        visited[temp_point[0] + dx[i]][temp_point[1] + dy[i]] = True;
                        stk_adj.append([temp_point[0]+dx[i],temp_point[1]+dy[i]])
    return reached

dx=[0,0,-1,1]
dy=[-1,1,0,0]
numbers = list(map(int, input().split()))
n=int(numbers[0])
m=int(numbers[1])
temp_line=""
cage=[['']*m for _ in range(n) ]
#vstd=numpy.zeros(10)
visited=[[False]*m for _ in range(n) ]
for i in range(0,n):
    temp_line=input()
    for j in range(0,m):
        cage[i][j]+=(temp_line[j])
numbers = list(map(int, input().split()))
i1=int(numbers[0]-1)
j1=int(numbers[1]-1)
numbers = list(map(int, input().split()))
i2=int(numbers[0]-1)
j2=int(numbers[1]-1)
pos=0
if(is_path_exist(cage, visited, i1, j1, i2, j2)):
    if(cage[i2][j2]=='X'):
        print('YES')
        pos=1
    if(pos==0):
        count=0
        for i in range(0,4):
            if (i2 + dx[i] > -1 and i2 + dx[i] < len(cage) and j2 + dy[i] > -1 and j2 + dy[i] < len(cage[0])
                        and (cage[i2 + dx[i]][j2 + dy[i]] == '.' or (i2 + dx[i] == i1 and j2 + dy[i] == j1)) ):
                count+=1
        if(count>1):
            print('YES')
        else:
            print('NO')
else:
    print('NO')