#include #define rep(i,n) for(int i=0;i<(int)(n);i++) #define chmin(x,y) x = min((x),(y)) #define chmax(x,y) x = max((x),(y)) #define popcount(x) __builtin_popcount(x) using namespace std; using ll = long long ; using P = pair ; using pll = pair; const int INF = 1e9; const long long LINF = 1e17; const int MOD = 1000000007; //const int MOD = 998244353; const double PI = 3.14159265358979323846; int dx[] = {-1,1,0,0}; int dy[] = {0,0,1,-1}; int main(){ int h,w; cin >> h >> w; vector cost(4); rep(i,4) cin >> cost[i]; ll k,p; cin >> k >> p; int xs,ys,xt,yt; cin >> xs >> ys >> xt >> yt; --xs;--ys;--xt;--yt; vector maze(h); rep(i,h) cin >> maze[i]; vector> dist(h,vector(w,LINF)); auto id = [&](int i,int j){return i+j*h;}; priority_queue,greater> pq; pq.push(pll{id(xs,ys),0}); while(!pq.empty()){ int x = pq.top().first % h; int y = pq.top().first / h; ll d = pq.top().second; pq.pop(); if(dist[x][y] <= d) continue; dist[x][y] = d; rep(k,4){ int new_x = x + dx[k]; int new_y = y + dy[k]; ll dis = d + cost[k]; if(new_x < 0 || h <= new_x || new_y < 0 || w <= new_y) continue; if(maze[new_x][new_y] == '#') continue; if(maze[new_x][new_y] == '@') dis += p; pq.push(pll{id(new_x,new_y),dis}); } } if(dist[xt][yt] <= k) cout << "Yes" << endl; else cout << "No" << endl; return 0; }