#include using namespace std; using ll = long long; using pint = pair; using pll = pair; using tpll = tuple; int main(){ const ll INF = 1e18; const vector dx = {-1, 1, 0, 0}, dy = {0, 0, 1, -1}; int H, W; cin >> H >> W; vector cost(4); for(int i = 0; i < 4; i++)cin >> cost[i]; ll K, P; cin >> K >> P; int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; --sx; --sy; --gx; --gy; vector grid(H); for(string &s: grid)cin >> s; priority_queue, greater> pq; vector> dist(H, vector(W, INF)); vector> vis(H, vector(W)); dist[sx][sy] = 0; pq.push({0, sx, sy}); while(pq.size()){ ll d, h, w; tie(d, h, w) = pq.top(); pq.pop(); if(vis[h][w])continue; vis[h][w] = true; for(int i = 0; i < 4; i++){ int nh = h + dx[i], nw = w + dy[i]; ll c = cost[i]; if(nh < 0 || nh > H - 1 || nw < 0 || nw > W - 1)continue; if(grid[nh][nw] == '#')continue; if(grid[nh][nw] == '@')c += P; if(dist[h][w] + c >= dist[nh][nw])continue; dist[nh][nw] = dist[h][w] + c; pq.push({dist[nh][nw], nh, nw}); } } if(dist[gx][gy] > K)cout << "No" << endl; else cout << "Yes" << endl; }