#include using namespace std; struct iofast_t { iofast_t() { ios::sync_with_stdio(false); cin.tie(nullptr); } } iofast; struct uns_t {} uns; template auto vec(Element init, Head arg, Args ...args) { if constexpr (sizeof...(Args) == 0) return std::vector(arg, init); else return std::vector(arg, vec(init, args...)); } template auto vec(uns_t, Head arg, Args ...args) { return vec(Element(), arg, args...); } template > T &chmin(T &l, T r, Compare &&f = less()) { return l = min(l, r, f); } template > T &chmax(T &l, T r, Compare &&f = less()) { return l = max(l, r, f); } template using pqueue = priority_queue, greater>; int main() { constexpr int64_t inf = INT64_MAX / 2; constexpr int step[4][2] = { { -1, 0 }, { 1, 0 }, { 0, 1 }, { 0, -1 }, }; int h, w; cin >> h >> w; int op[4] = {}; for (auto &e : op) cin >> e; int64_t k, p; cin >> k >> p; int sy, sx; cin >> sy >> sx; --sy; --sx; int ty, tx; cin >> ty >> tx; --ty; --tx; auto f = vec(uns, h); for (auto &e : f) cin >> e; pqueue> que; auto dist = vec(inf, h, w); que.push({ 0, sy, sx }); dist[sy][sx] = 0; while (!empty(que)) { auto [c, y, x] = que.top(); que.pop(); if (dist[y][x] < c) { continue; } for (int i = 0; i < 4; ++i) { auto [dy, dx] = step[i]; int ny = y + dy; int nx = x + dx; if (min(ny, nx) < 0 || h <= ny || w <= nx) { continue; } if (f[ny][nx] == '#') { continue; } int64_t cost = op[i]; if (f[ny][nx] == '@') { cost += p; } if (dist[ny][nx] <= c + cost) { continue; } dist[ny][nx] = c + cost; que.push({ c + cost, ny, nx }); } } cout << (dist[ty][tx] <= k ? "Yes" : "No") << endl; }