#include using namespace std; void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); } int main() { fast_io(); int h, w; cin >> h >> w; int cost[4]; long long k, p; cin >> cost[0] >> cost[1] >> cost[2] >> cost[3] >> k >> p; int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; xs--, ys--, xt--, yt--; vector c(h); for (int i = 0; i < h; i++) { cin >> c[i]; } long long INF = 1e18; vector> dist(h, vector(w, INF)); dist[xs][ys] = 0; using tlii = tuple; priority_queue, greater> pq; pq.push({0, xs, ys}); vector> vis(h, vector(w)); int dx[] = {-1, 1, 0, 0}; int dy[] = {0, 0, 1, -1}; auto is_in = [&](int x, int y) { return x >= 0 && x < h && y >= 0 && y < w; }; while (!pq.empty()) { auto [d, x, y] = pq.top(); pq.pop(); if (vis[x][y]) continue; vis[x][y] = true; for (int dir = 0; dir < 4; dir++) { int nx = x + dx[dir]; int ny = y + dy[dir]; if (!is_in(nx, ny) || c[nx][ny] == '#') continue; long long w = cost[dir] + (c[nx][ny] == '@' ? p : 0); if (dist[nx][ny] > dist[x][y] + w) { dist[nx][ny] = dist[x][y] + w; pq.push({dist[nx][ny], nx, ny}); } } } cout << (dist[xt][yt] <= k ? "Yes" : "No") << endl; }