#pragma region #define _USE_MATH_DEFINES #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace atcoder; //using mint = modint1000000007; using mint = modint998244353; //using mint = modint; #pragma region using using namespace std; typedef long long ll; using vi = vector; using vvi = vector; using vl = vector; using vvl = vector; using vmint = vector; using vvmint = vector; using pint = pair; using pll = pair; using vpint = vector; using vvpint = vector; using vd = vector; using vvd = vector; using vs = vector; using vvs = vector; //#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i)) #define rep(i, e) for (int(i) = 0; (i) < (e); ++(i)) #define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i)) #define all(x) x.begin(),x.end() #define rall(x) x.rbegin(),x.rend() #pragma endregion #pragma region UnionFind struct UnionFind { vector par; UnionFind(int n) : par(n, -1) {} void init(int n) { par.assign(n, -1); } int root(int x) { if (par[x] < 0) return x; else return par[x] = root(par[x]); } bool issame(int x, int y) { return root(x) == root(y); } bool merge(int x, int y) { x = root(x); y = root(y); if (x == y) return false; if (par[x] > par[y]) swap(x, y); par[x] += par[y]; par[y] = x; return true; } int size(int x) { return -par[root(x)]; } }; #pragma endregion #pragma region GCD ll gcd(ll a, ll b) { if (b == 0)return a; return gcd(b, a%b); } #pragma endregion #pragma region LCM ll lcm(ll a, ll b) { return a / gcd(a, b) * b; } #pragma endregion #pragma region chmin template inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; } #pragma endregion #pragma region chmax template inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; } #pragma endregion #pragma region Dijkstra vl dijkstra(vector>> v, int s) { ll INF = 1e18; int MAX = 1e6; vl res(MAX, INF); priority_queue, vector>, greater>> q; q.push({ 0,s }); while (!q.empty()) { int now; ll d; tie(d, now) = q.top(); q.pop(); if (!chmin(res[now], d))continue; for (auto p : v[now]) { int next; ll c; tie(next, c) = p; if (res[next] <= res[now] + c)continue; q.push({ res[now] + c,next }); } } return res; } #pragma endregion #pragma region degからrad double dtor(double deg) { return deg * M_PI / 180; } #pragma endregion #pragma region radからdeg double rtod(double r) { return r * 180 / M_PI; } #pragma endregion #pragma region グリッド内チェック bool out(int x, int y, int h, int w) { if (x < 0 || h <= x || y < 0 || w <= y)return true; else return false; } #pragma endregion #pragma endregion int main() { int h, w; cin >> h >> w; ll U, D, R, L, K, P; cin >> U >> D >> R >> L >> K >> P; int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; --xs, --ys, --xt, --yt; vs v(h); rep(i, h)cin >> v[i]; ll INF = 1e18; vvl dp(h, vl(w, INF)); priority_queue, vector>, greater>> q; q.push({ 0,xs,ys }); while (!q.empty()) { auto p = q.top(); ll cost = get<0>(p); int x = get<1>(p), y = get<2>(p); q.pop(); if (!chmin(dp[x][y], cost))continue; int nx, ny; nx = x - 1, ny = y; if (!out(nx, ny, h, w)) { if (v[nx][ny] == '.' && dp[nx][ny] > cost + U)q.push({ cost + U,nx,ny }); else if (v[nx][ny] == '@' && dp[nx][ny] > cost + U + P)q.push({ cost + U + P,nx,ny }); } nx = x + 1, ny = y; if (!out(nx, ny, h, w)) { if (v[nx][ny] == '.' && dp[nx][ny] > cost + D)q.push({ cost + D,nx,ny }); else if (v[nx][ny] == '@' && dp[nx][ny] > cost + D + P)q.push({ cost + D + P,nx,ny }); } nx = x, ny = y - 1; if (!out(nx, ny, h, w)) { if (v[nx][ny] == '.' && dp[nx][ny] > cost + L)q.push({ cost + L,nx,ny }); else if (v[nx][ny] == '@' && dp[nx][ny] > cost + L + P)q.push({ cost + L + P,nx,ny }); } nx = x, ny = y + 1; if (!out(nx, ny, h, w)) { if (v[nx][ny] == '.' && dp[nx][ny] > cost + R)q.push({ cost + R,nx,ny }); else if (v[nx][ny] == '@' && dp[nx][ny] > cost + R + P)q.push({ cost + R + P,nx,ny }); } } if (dp[xt][yt] <= K)cout << "Yes" << endl; else cout << "No" << endl; }