#include long long int dist[102][102]; int h[200005], hl; int comp_h(int a, int b) { if (dist[h[a] / 101][h[a] % 101] > dist[h[b] / 101][h[b] % 101]) return 1; else return -1; } void swap_h(int a, int b) { int f = h[a]; h[a] = h[b]; h[b] = f; return; } void push(int ne) { h[hl] = ne; int p = hl; hl++; for (; p > 0; p = (p - 1) / 2) if (comp_h((p - 1) / 2, p) > 0) swap_h((p - 1) / 2, p); return; } int pop() { hl--; swap_h(0, hl); int p = 0; for (;;) { if (2 * p + 2 < hl) { if (comp_h(2 * p + 1, 2 * p + 2) > 0) { if (comp_h(p, 2 * p + 2) > 0) swap_h(p, 2 * p + 2); p = 2 * p + 2; } else { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } } else if (2 * p + 1 < hl) { if (comp_h(p, 2 * p + 1) > 0) swap_h(p, 2 * p + 1); p = 2 * p + 1; } else break; } return h[hl]; } int main() { int h, w; scanf("%d %d", &h, &w); long long int u, d, r, l, k, p; scanf("%lld %lld %lld %lld %lld %lld", &u, &d, &r, &l, &k, &p); int xs, ys, xt, yt; scanf("%d %d %d %d", &xs, &ys, &xt, &yt); xs--; xt--; ys--; yt--; char c[102][102]; int i, j; for (i = 0; i < h; i++) scanf("%s", c[i]); for (i = 0; i < h; i++) for (j = 0; j < w; j++) dist[i][j] = k + 10; hl = 0; dist[xs][ys] = 0; push(101 * xs + ys); while (hl > 0) { i = pop(); j = i % 101; i /= 101; if (i > 0) { if (c[i - 1][j] == '.' && dist[i - 1][j] > dist[i][j] + u) { dist[i - 1][j] = dist[i][j] + u; push(101 * (i - 1) + j); } else if (c[i - 1][j] == '@' && dist[i - 1][j] > dist[i][j] + u + p) { dist[i - 1][j] = dist[i][j] + u + p; push(101 * (i - 1) + j); } } if (i < h - 1) { if (c[i + 1][j] == '.' && dist[i + 1][j] > dist[i][j] + d) { dist[i + 1][j] = dist[i][j] + d; push(101 * (i + 1) + j); } else if (c[i + 1][j] == '@' && dist[i + 1][j] > dist[i][j] + d + p) { dist[i + 1][j] = dist[i][j] + d + p; push(101 * (i + 1) + j); } } if (j > 0) { if (c[i][j - 1] == '.' && dist[i][j - 1] > dist[i][j] + l) { dist[i][j - 1] = dist[i][j] + l; push(101 * i + j - 1); } else if (c[i][j - 1] == '@' && dist[i][j - 1] > dist[i][j] + l + p) { dist[i][j - 1] = dist[i][j] + l + p; push(101 * i + j - 1); } } if (j < w - 1) { if (c[i][j + 1] == '.' && dist[i][j + 1] > dist[i][j] + r) { dist[i][j + 1] = dist[i][j] + r; push(101 * i + j + 1); } else if (c[i][j + 1] == '@' && dist[i][j + 1] > dist[i][j] + r + p) { dist[i][j + 1] = dist[i][j] + r + p; push(101 * i + j + 1); } } } if (dist[xt][yt] <= k) printf("Yes\n"); else printf("No\n"); return 0; }