import std.stdio; import std.array; import std.string; import std.conv; import std.algorithm; import std.typecons; import std.range; import std.random; import std.math; import std.container; void main() { auto input = readln.split.map!(to!int); int H = input[0]; int W = input[1]; input = readln.split.map!(to!int); int A = input[0]; int Si = input[1]; int Sj = input[2]; input = readln.split.map!(to!int); int C = input[0]; int Gi = input[1]; int Gj = input[2]; string[] B = new string[](H); foreach (i; iota(H)) B[i] = readln.chomp; DList!(Tuple!(int, int, int)) queue; queue.insert(tuple(Si, Sj, A)); int i, j, s; Tuple!(int, int, int) node; bool[long] visited; int[4] dx = [0, 0, 1, -1]; int[4] dy = [1, -1, 0, 0]; while (!queue.empty()) { node = queue.front; queue.removeFront(); i = node[0]; j = node[1]; s = node[2]; if (i == Gi && j == Gj && s == C) { writeln("YES"); return; } if (i*100000000.to!long+j*1000000+s*10000 in visited) continue; visited[i*100000000.to!long+j*1000000+s*10000] = true; foreach (k; iota(4)) { int ni = i + dx[k]; int nj = j + dy[k]; if (ni < 0 || ni >= H || nj < 0 || nj >= W) continue; int ns = B[ni][nj] == '*' ? s + 1 : s - 1; if (ns <= 0 || ns > 10000 || ni*100000000.to!long+nj*1000000+ns*10000 in visited) continue; queue.insert(tuple(ni, nj, ns)); } } writeln("NO"); }