using System; using System.Linq; using System.Text; using System.Collections.Generic; using STR = System.String; using INT = System.Int32; using DEC = System.Double; class Program { public static IO IO = new IO(); public struct MEMODATA { public INT SIZE; public INT X; public INT Y; public MEMODATA(INT size, INT x, INT y) { SIZE = size; X = x; Y = y; } public bool SAME(MEMODATA t) { return SIZE == t.SIZE && X == t.X && Y == t.Y; } } static void Main(string[] args) { INT[] hw = IO.I(' '); INT[] a = IO.I(' '); INT[] b = IO.I(' '); STR[] s = IO.S(hw[0]); INT[] x = new INT[4] { -1, 0, 1, 0 }; INT[] y = new INT[4] { 0, 1, 0, -1 }; bool[,,] memo = new bool[100000, hw[0], hw[1]]; QUEUE q = new QUEUE(1001 * hw[0] * hw[1]); MEMODATA c = new MEMODATA(b[0], b[1], b[2]); Func MEMOCHECK = (INT SIZE, INT X, INT Y) => { if (!memo[SIZE, X, Y]) { return memo[SIZE, X, Y] = true; } else { return false; } }; string o = "No"; MEMOCHECK(a[0], a[1], a[2]); q.PUSH(new MEMODATA(a[0], a[1], a[2])); long aaa = 0; while (q.SIZE() != 0) { MEMODATA data = q.POP(); if (data.SAME(c)) { o = "Yes"; break; } for (int i = 0; i < 4; i++) { INT nx = data.X + x[i]; INT ny = data.Y + y[i]; if (nx >= 0 && nx < hw[0] && ny >= 0 && ny < hw[1]) { INT nsize = data.SIZE + ((s[nx][ny] == '*') ? 1 : -1); if (nsize > 0 && nsize < 2500) { if (MEMOCHECK(nsize, nx, ny)) { q.PUSH(new MEMODATA(nsize, nx, ny)); } } } } aaa++; } IO.W(o); IO.F(); } } public class QUEUE { protected INT m; private INT s, e, c; private T[] q; public QUEUE(INT max) { m = max; q = new T[m]; CLEAR(); } public void CLEAR() { e = 0; s = 0; c = 0; } public INT SIZE() { return c; } public T TOP() { return q[s]; } public T POP() { T r = q[s++]; s %= m; c--; return r; } public virtual void PUSH(T v) { q[e++] = v; e %= m; c++; } public bool EMPTY() { return SIZE() == 0; } } public class IO { private const int WMAX = 1000; private StringBuilder SB = new StringBuilder(); private T R(Func f) { return f(Console.ReadLine()); } private T[] R(Func f, char c) { return S().Split(c).Select(f).ToArray(); } private T[] R(Func f, INT l) { T[] r = new T[l]; for (INT i = 0; i < l; i++) { r[i] = R(f); } return r; } private T[][] R(Func f, INT l, char c) { T[][] r = new T[l][]; for (INT i = 0; i < l; i++) { r[i] = R(f, c); } return r; } private void W(Func f, T v, bool lf = true) { SB.Append(f(v)); if (lf) { SB.Append('\n'); } if (SB.Length >= WMAX) { F(); } } public STR S() { return R(s => s); } public STR[] S(char c) { return R(s => s, c); } public STR[] S(INT l) { return R(s => s, l); } public STR[][] S(INT l, char c) { return R(s => s, l, c); } public INT I() { return R(INT.Parse); } public INT[] I(char c) { return R(INT.Parse, c); } public INT[] I(INT l) { return R(INT.Parse, l); } public INT[][] I(INT l, char c) { return R(INT.Parse, l, c); } public DEC D() { return R(DEC.Parse); } public DEC[] D(char c) { return R(DEC.Parse, c); } public DEC[] D(INT l) { return R(DEC.Parse, l); } public DEC[][] D(INT l, char c) { return R(DEC.Parse, l, c); } public void W(object s, bool lf = true) { W(v => v.ToString(), s, lf); } public void F() { Console.Write(SB); SB.Length = 0; } }