#include using namespace std; using ll = long long; int main() { ios_base::sync_with_stdio(false); cin.tie(nullptr); const ll INF = 1e18; int H, W; cin >> H >> W; int U, D, R, L, P; ll K; cin >> U >> D >> R >> L >> K >> P; int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; --xs, --ys, --xt, --yt; vector C(H); for (auto& x : C) cin >> x; vector dist(H, vector>(W, vector(H+W, INF))); dist[xs][ys][0] = 0; vector dx = {-1, 1, 0, 0}; vector dy = {0, 0, 1, -1}; vector cost = {U, D, R, L}; using T = tuple; priority_queue, greater> pq; pq.push({0, xs, ys, 0}); while (!pq.empty()) { ll d; int x, y, t; tie(d, x, y, t) = pq.top(); pq.pop(); if (dist[x][y][t] < d) continue; for (int k = 0; k < 4; ++k) { int nx = x + dx[k], ny = y + dy[k]; if (0 <= nx && nx < H && 0 <= ny && ny <= W && C[nx][ny] != '#') { if (C[nx][ny] == '.' && dist[nx][ny][t] > d + cost[k]) { dist[nx][ny][t] = d + cost[k]; pq.push({dist[nx][ny][t], nx, ny, t}); } if (C[nx][ny] == '@' && t+1 < H+W && dist[nx][ny][t+1] > d + cost[k] + P) { dist[nx][ny][t+1] = d + cost[k] + P; pq.push({dist[nx][ny][t+1], nx, ny, t+1}); } } } } for (int t = 0; t < H + W; ++t) { if (dist[xt][yt][t] <= K) { cout << "Yes" << endl; return 0; } } cout << "No" << endl; }