#include "bits/stdc++.h" #define int long long using namespace std; using ll = long long; using P = pair; const ll INF = (1LL << 61); ll mod = 1000000007; int N, M; vector>edge[100010]; vector dijkstra(int s) { priority_queue, greater

>pq; vectordist(N * M, INF); dist[s] = 0; pq.push({ dist[s],s }); while (!pq.empty()) { P p = pq.top(); pq.pop(); ll d = p.first, from = p.second; if (dist[from] < d)continue; for (auto nv : edge[from]) { ll to = nv.first; ll cost = nv.second; if (dist[from] + cost < dist[to]) { dist[to] = dist[from] + cost; pq.push({ dist[to],to }); } } } return dist; } int f(int i, int j) { return i * M + j; } signed main() { ios::sync_with_stdio(false); cin.tie(0); cin >> N >> M; int U, D, R, L, K, p; cin >> U >> D >> R >> L >> K >> p; int sx, sy, gx, gy; cin >> sx >> sy >> gx >> gy; sx--; sy--; gx--; gy--; vector>C(N, vector(M)); for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { cin >> C[i][j]; } } for (int i = 0; i < N; i++) { for (int j = 0; j < M; j++) { if (C[i][j] == '#')continue; int cost = 0; // i - 1 if (i > 0 && C[i - 1][j] != '#') { cost = U; if (C[i - 1][j] == '@')cost += p; edge[f(i, j)].push_back({ f(i - 1, j), cost }); } // i + 1 if (i < N - 1 && C[i + 1][j] != '#') { cost = D; if (C[i + 1][j] == '@')cost += p; edge[f(i, j)].push_back({ f(i + 1, j), cost }); } // j + 1 if (j < M - 1 && C[i][j + 1] != '#') { cost = R; if (C[i][j + 1] == '@')cost += p; edge[f(i, j)].push_back({ f(i, j + 1), cost }); } // j - 1 if (j > 0 && C[i][j - 1] != '#') { cost = L; if (C[i][j - 1] == '@')cost += p; edge[f(i, j)].push_back({ f(i, j - 1), cost }); } } } auto d = dijkstra(f(sx, sy)); int ans = d[f(gx, gy)]; if (ans <= K)cout << "Yes" << endl; else cout << "No" << endl; return 0; }