#include using namespace std; using Int = long long; const char newl = '\n'; template inline void chmin(T1 &a,T2 b){if(a>b) a=b;} template inline void chmax(T1 &a,T2 b){if(a void drop(const T &x){cout< vector read(size_t n){ vector ts(n); for(size_t i=0;i>ts[i]; return ts; } template struct Dijkstra{ struct Edge{ Int to; T cost; Edge(Int to,T cost):to(to),cost(cost){} bool operator<(const Edge &o)const{return cost>o.cost;} }; vector< vector > G; vector ds; vector bs; Dijkstra(Int n):G(n){} void add_edge(Int u,Int v,T c){ G[u].emplace_back(v,c); } void build(Int s){ Int n=G.size(); ds.assign(n,numeric_limits::max()); bs.assign(n,-1); priority_queue pq; ds[s]=0; pq.emplace(s,ds[s]); while(!pq.empty()){ auto p=pq.top();pq.pop(); Int v=p.to; if(ds[v]ds[v]+e.cost){ ds[e.to]=ds[v]+e.cost; bs[e.to]=v; pq.emplace(e.to,ds[e.to]); } } } } T operator[](Int k){return ds[k];} vector restore(Int to){ vector res; if(bs[to]<0) return res; while(~to) res.emplace_back(to),to=bs[to]; reverse(res.begin(),res.end()); return res; } }; template struct Grid{ const int h,w; const F f; Grid(int h_,int w_,F f_):h(h_),w(w_),f(f_){} int idx(int y,int x){return y*w+x;} using T = typename invoke_result::type; T operator[](int k){return f(k/w,k%w);} decltype(auto) edges(){ vector> es; for(int i=0;i>h>>w; Int u,d,r,l,k,p; cin>>u>>d>>r>>l>>k>>p; Int ys,xs,yt,xt; cin>>ys>>xs>>yt>>xt; ys--;xs--;yt--;xt--; auto C=read(h); map cost; cost[-w]=u; cost[+w]=d; cost[+1]=r; cost[-1]=l; Grid G(h,w,[&](int y,int x){return C[y][x];}); Dijkstra D(h*w); for(auto[a,b]:G.edges()){ if(G[a]=='#' or G[b]=='#') continue; D.add_edge(a,b,cost[b-a]+p*(G[b]=='@')); D.add_edge(b,a,cost[a-b]+p*(G[a]=='@')); } D.build(G.idx(ys,xs)); cout<<(D[G.idx(yt,xt)]<=k?"Yes":"No")<