#include using namespace std; using vertex = tuple; constexpr int64_t inf = 1e18; vector dx{-1, 1, 0, 0}, dy{0, 0, 1, -1}, cost(4); int main() { int h, w; cin >> h >> w; for (int i = 0; i < 4; i++) { cin >> cost.at(i); } int64_t k, p; cin >> k >> p; int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; sx--; sy--; tx--; ty--; vector c(h); for (auto &&s : c) { cin >> s; } vector total(h, vector(w, inf)); priority_queue, greater> q; q.emplace(0, sx, sy); while (not q.empty()) { auto [d0, x, y] = q.top(); q.pop(); if (d0 >= total.at(x).at(y)) { continue; } total.at(x).at(y) = d0; for (int i = 0; i < 4; i++) { int x_next = x + dx.at(i), y_next = y + dy.at(i), d_next = d0 + cost.at(i); if (x_next < 0 or h <= x_next or y_next < 0 or w <= y_next) { continue; } if (c.at(x_next).at(y_next) == '#') { continue; } if (c.at(x_next).at(y_next) == '@') { d_next += p; } if (d_next >= total.at(x_next).at(y_next)) { continue; } q.emplace(d_next, x_next, y_next); } } if (total.at(tx).at(ty) <= k) { puts("Yes"); } else { puts("No"); } return 0; }