import std; struct Grid { int x; int y; int cost; } void main() { int H, W; readf("%d %d\n", H, W); int U, D, R, L, K, P; readf("%d %d %d %d %d %d\n", U, D, R, L, K, P); int xs, ys, xt, yt; readf("%d %d %d %d\n", xs, ys, xt, yt); --xs, --ys, --xt, --yt; auto C = new string[](H); foreach (i; 0 .. H) { C[i] = readln.chomp; } auto costs = new int[][](H, W); foreach (i; 0 .. H) { costs[i][] = int.max; } costs[xs][ys] = 0; auto move = [ Grid(-1, 0, U), Grid(1, 0, D), Grid(0, 1, R), Grid(0, -1, L) ]; auto que = new BinaryHeap!(Array!Grid, "a.cost > b.cost")(); que.insert(Grid(xs, ys, 0)); while (!que.empty) { auto f = que.front; que.popFront; foreach (m; move) { auto next = f; next.x += m.x, next.y += m.y, next.cost += m.cost; if (next.x < 0 || next.x >= H || next.y < 0 || next.y >= W) { continue; } if (C[next.x][next.y] == '#') { continue; } else if (C[next.x][next.y] == '@') { next.cost += P; } if (costs[next.x][next.y] <= next.cost) { continue; } costs[next.x][next.y] = next.cost; que.insert(next); } } if (costs[xt][yt] <= K) { writeln("Yes"); } else { writeln("No"); } }