#include #define rep(i,n) for(int i = 0; i < (n); i++) using namespace std; typedef long long ll; // g <- pair < v , cost > template < class T > vector< T > dijkstra(vector>> &graph, int s) { T INF = numeric_limits< T >::max(); vector dist(graph.size(), INF); priority_queue, vector>, greater>> q; q.push({dist[s] = T(0), s}); while(!q.empty()){ auto [uc, ui] = q.top(); q.pop(); if(uc != dist[ui]) continue; for(auto [vi, vc] : graph[ui]) if(dist[vi] > uc + vc) q.push({dist[vi] = uc + vc, vi}); } return dist; } int main(){ cin.tie(0); ios::sync_with_stdio(0); ll H,W,U,D,R,L,K,P; cin >> H >> W >> U >> D >> R >> L >> K >> P; int xs,ys,xt,yt; cin >> xs >> ys >> xt >> yt; xs--, ys--, xt--, yt--; vector C(H); rep(i,H) cin >> C[i]; vector>> G(H * W); auto h = [&](int i, int j){ return i * W + j; }; int di[] = {-1, +1, 0, 0}; int dj[] = {0, 0, +1, -1}; ll cost[] = {U, D, R, L}; rep(i,H)rep(j,W)if(C[i][j] != '#')rep(d,4) { int ni = i + di[d], nj = j + dj[d]; if(0 <= ni && ni < H && 0 <= nj && nj < W) { if(C[ni][nj] == '.') { G[h(i, j)].push_back({h(ni, nj), cost[d]}); } else if(C[ni][nj] == '@') { G[h(i, j)].push_back({h(ni, nj), P}); } } } cout << (dijkstra(G, h(xs, ys))[h(xt, yt)] <= K ? "Yes" : "No") << endl; }