#include #define rep(i, l, r) for (int i = (l); i < (r); i++) using namespace std; typedef long long ll; int main() { int H, W, xs, ys, xt, yt, dx[4] = {-1, 1, 0, 0}, dy[4] = {0, 0, 1, -1}; vector cost(4); ll K, P; cin >> H >> W; rep(i, 0, 4) cin >> cost[i]; cin >> K >> P >> xs >> ys >> xt >> yt; xs--; ys--; xt--; yt--; vector C(H); rep(i, 0, H) cin >> C[i]; vector> A(H, vector(W, 1e18)); priority_queue> q; A[xs][ys] = 0; q.push({0, xs, ys}); while (!q.empty()) { auto r = q.top(); q.pop(); ll d = -r[0], x = r[1], y = r[2]; //cout << "d=" << d << " x=" << x << " y=" << y << endl; rep(i, 0, 4) { int nx = x + dx[i], ny = y + dy[i]; if (nx < 0 || nx >= H || ny < 0 || ny >= W) continue; if (C[nx][ny] == '#') continue; ll nd = d + cost[i]; if (C[nx][ny] == '@') nd += P; if (nd >= A[nx][ny]) continue; A[nx][ny] = nd; q.push({-nd, nx, ny}); } } if (A[xt][yt] > K) cout << "No" << endl; else cout << "Yes" << endl; }