#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include //eolibraries #define lnf 3999999999999999999 #define inf 999999999 #define fi first #define se second #define pb push_back #define ll long long #define ld long double #define all(c) (c).begin(),(c).end() #define sz(c) (ll)(c).size() #define make_unique(a) sort(all(a)),a.erase(unique(all(a)),a.end()) #define pii pair #define tpii pair #define rep(i,n) for(ll i = 0 ; i < n ; i++) #define drep(i,n) for(ll i = n-1 ; i >= 0 ; i--) #define crep(i,x,n) for(ll i = x ; i < n ; i++) #define vi vector #define vec(...) vector<__VA_ARGS__> #define _37ckhvj ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0) //eodefine using namespace std; const ll mxn=12000; const ll di[]={1,-1,0,0}; const ll dj[]={0,0,1,-1}; int main(){ _37ckhvj; ll h,w; cin>>h>>w; vi mvcost(4,0); rep(i,4) cin>>mvcost[i]; ll k,_p; cin>>k>>_p; ll xs,ys,xt,yt; cin>>xs>>ys>>xt>>yt; xs--; ys--; xt--; yt--; vec(vec(char)) a(h,vec(char)(w)); rep(i,h) rep(j,w) cin>>a[i][j]; vec(vec(ll)) dp(h,vi(w,lnf)); if(a[xs][ys]=='#'){ cout<<"No\n"; exit(0); } priority_queue,greater> pq; pq.push({0,{xs,ys}}); dp[xs][ys]=0; auto ok=[&](ll x,ll y){ bool pok=1; if(min(x,y)<0) return pok=0; if(x>=h or y>=w) return pok=0; if(a[x][y]=='#') return pok=0; return pok=1; }; while(sz(pq)){ tpii top=pq.top(); pii p=top.se; pq.pop(); if(top.fi!=dp[p.fi][p.se]) continue; // cout<cost){ dp[nei][nej]=cost; pq.push({cost,{nei,nej}}); } } } } if(dp[xt][yt]>k){ cout<<"No\n"; }else{ cout<<"Yes\n"; } // return 0; }