#include #include #include #include using namespace std; using i32 = int32_t; using i64 = int64_t; #define rep(i,n) for(int i=0; i<(n); i++) const i64 INF = 1001001001001001; struct Edge{ int to; i64 d; }; int H,W; i64 X[6]; int sy,sx,ty,tx; string G; vector> E; vector D; int main(){ cin >> H >> W; rep(t,6) cin >> X[t]; cin >> sy >> sx >> ty >> tx; sy--; sx--; ty--; tx--; rep(y,H){ string g; cin >> g; G += g; } E.resize(H*W); rep(y,H) rep(x,W){ int p = y * W + x; if(y != 0){ E[p].push_back({p-W,X[0]}); E[p-W].push_back({p,X[1]}); } if(x != 0){ E[p].push_back({p-1,X[3]}); E[p-1].push_back({p,X[2]}); } } rep(p,H*W){ for(auto& e : E[p]){ if(G[e.to] == '#') e.d = INF; if(G[e.to] == '@') e.d += X[5]; } } D.assign(H*W,INF); priority_queue> G; G.push({0,sy*W+sx}); D[sy*W+sx] = 0; while(G.size()){ int p = G.top().second; i64 d = -G.top().first; G.pop(); if(D[p] != d) continue; for(auto e : E[p]){ i64 nxd = e.d + d; if(nxd >= D[e.to]) continue; D[e.to] = nxd; G.push({-nxd,e.to}); } } if(D[ty*W+tx] <= X[4]) cout << "Yes\n"; else cout << "No\n"; return 0; } struct ios_do_not_sync{ ios_do_not_sync(){ ios::sync_with_stdio(false); cin.tie(nullptr); } } ios_do_not_sync_instance;