#include using namespace std; typedef long long ll; typedef pair p_ll; template void debug(T itr1, T itr2) { auto now = itr1; while(now=0; i--) #define popcount __builtin_popcount const ll LLINF = pow(2,61)-1; const ll INF = pow(2,30)-1; ll gcd(ll a, ll b) { if (a>> adj; vector> minlen; dijkstra2d(ll n, ll m) { N = n; M = m; adj.resize(N); rep(i,N) adj[i].resize(M); minlen.resize(N); rep(i,N) minlen[i].assign(M,LLINF); } void add_edge(p_ll from, p_ll to, ll d) { adj[from.first][from.second].push_back({to,d}); } vector> calc(ll n=0, ll m=0) { auto c = [](const pair &x, const pair &y){return x.second>y.second;}; priority_queue, vector>, decltype(c)> q(c); minlen[n][m] = 0; q.push(make_pair(make_pair(n,m),0)); while(q.size()) { pair now = q.top(); q.pop(); p_ll np = now.first; ll np1 = np.first, np2 = np.second; ll nd = now.second; if (nd>minlen[np1][np2]) continue; for (auto x: adj[np1][np2]) { ll xt1 = x.to.first, xt2 = x.to.second; if (minlen[xt1][xt2]<=minlen[np1][np2]+x.d) continue; q.push(make_pair(make_pair(xt1, xt2), minlen[np1][np2]+x.d)); minlen[xt1][xt2] = minlen[np1][np2]+x.d; } } return minlen; } }; // ---------------------------------------------------------------------- // ---------------------------------------------------------------------- int main() { ll H, W; cin >> H >> W; ll U, D, R, L, K; cin >> U >> D >> R >> L >> K; ll cost = (D+1)*(R+1)*(U+1)*(L+1); string C[H]; rep(i,H) cin >> C[i]; ll xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; xs--; ys--; xt--; yt--; dijkstra2d dk(H,W); rep(i,H) rep(j,W) { if (i!=H-1) { if (C[i+1][j]=='.') dk.add_edge(make_pair(i,j), make_pair(i+1,j), D); else if (C[i+1][j]=='@') dk.add_edge(make_pair(i,j), make_pair(i+1,j), cost+D); if (C[i][j]=='.') dk.add_edge(make_pair(i+1,j), make_pair(i,j), U); else if (C[i][j]=='@') dk.add_edge(make_pair(i+1,j), make_pair(i,j), cost+U); } if (j!=W-1) { if (C[i][j+1]=='.') dk.add_edge(make_pair(i,j), make_pair(i,j+1), R); else if (C[i][j+1]=='@') dk.add_edge(make_pair(i,j), make_pair(i,j+1), cost+R); if (C[i][j]=='.') dk.add_edge(make_pair(i,j+1), make_pair(i,j), L); else if (C[i][j]=='@') dk.add_edge(make_pair(i,j+1), make_pair(i,j), cost+L); } } vector> d = dk.calc(xs,ys); // for (auto x: d) debug(all(x)); string result = d[xt][yt]<=K ? "Yes" : "No"; cout << result << endl; return 0; }