Seonjin's Frozen Kingdom

Decide whether a walk on a grid that breaks each cell it leaves can visit the hatch cell, leave it, and step back onto it.

Hard8DFSGraphNo attempts yetTime limit2sMemory limit256 MB

Problem

Seonjin, the only descendant of Olaf from the frozen kingdom, is standing on a sheet of ice that Elsa froze.

The ice is a rectangular grid of nn rows and mm columns, and the ice on each cell is either damaged or undamaged. A damaged cell is given as the capital letter X and an undamaged cell as .. Rows are numbered 1 to nn from top to bottom, and columns are numbered 1 to mm from left to right.

If Seonjin steps onto a damaged cell, he falls through the ice and freezes to death. He must therefore move only to a cell that is adjacent up, down, left, or right and is undamaged. The ice is thin, so once he moves to another cell, the ice on the cell he just left turns damaged.

(a)(b)

For example, Seonjin stands at (1,1)(1, 1) as in picture (a). If he moves one cell to the right as in picture (b), his position becomes (1,2)(1, 2) and the ice at (1,1)(1, 1) is damaged, so he can never cross it again.

The escape hatch Olaf built lies under the ice at (r2,c2)(r_2, c_2). To use it, Seonjin has to damage the ice at (r2,c2)(r_2, c_2) and then step on that damaged ice again so that he drops through. The ice above the hatch may already be damaged at the start.

Given the initial state of the ice, Seonjin's starting position (r1,c1)(r_1, c_1), and the hatch position (r2,c2)(r_2, c_2), write a program that decides whether Seonjin can escape.

Input

The first line contains two integers nn and mm (1n,m5001 \le n, m \le 500). nn is the number of rows of the grid and mm is the number of columns.

Each of the next nn lines contains mm characters describing the initial state of the ice. Damaged ice is written as X and undamaged ice as ..

The next line contains two integers r1r_1 and c1c_1 (1r1n1 \le r_1 \le n, 1c1m1 \le c_1 \le m). This is Seonjin's starting position, and the state of that cell is always X.

The next line contains two integers r2r_2 and c2c_2 (1r2n1 \le r_2 \le n, 1c2m1 \le c_2 \le m). This is the position of the hatch Olaf built, and it may be the same as the starting position.

Output

Print YES if Seonjin can escape, and NO otherwise.

Hint

In the first example he escapes by moving in the order (1,6)(2,6)(3,6)(4,6)(4,5)(4,4)(4,3)(4,2)(4,1)(3,1)(2,1)(2,2)(2,3)(1,3)(1,2)(2,2)(1, 6) \to (2, 6) \to (3, 6) \to (4, 6) \to (4, 5) \to (4, 4) \to (4, 3) \to (4, 2) \to (4, 1) \to (3, 1) \to (2, 1) \to (2, 2) \to (2, 3) \to (1, 3) \to (1, 2) \to (2, 2).