#include using namespace std; int dx[] = {1,-1,0,0}; int dy[] = {0,0,1,-1}; int dz[] = {0,0,0,0}; bool chmin(long long &x,long long y) { if(x > y) { x = y; return true; } return false; } int main() { int H,W; cin >> H >> W >> dz[0] >> dz[1] >> dz[2] >> dz[3]; long long K; int P; cin >> K >> P; int a,b,c,d; cin >> a >> b >> c >> d; a--; b--; c--; d--; vector>>road(H*W); vectorS(H); for(int i = 0; i < H; i++) { cin >> S[i]; } for(int i = 0; i < H; i++) { for(int j = 0; j < W; j++) { for(int k = 0; k < 4; k++) { int nx = i+dx[k]; int ny = j+dy[k]; if(nx >= 0 && nx < H && ny >= 0 && ny < W) { if(S[nx][ny] == '#') { continue; } if(S[nx][ny] == '@') { road[i*W+j].push_back({nx*W+ny,P+dz[k]}); } else { road[i*W+j].push_back({nx*W+ny,dz[k]}); } } } } } vectordist(H*W,1001001001); dist[a*W+b] = 0; priority_queue,vector>,greater>>que; que.push({0,a*W+b}); while (!que.empty()) { pairx = que.top(); que.pop(); if(dist[x.second] != x.first) { continue; } for(int i = 0; i < road[x.second].size(); i++) { if(chmin(dist[road[x.second][i].first],road[x.second][i].second+x.first)) { que.push({dist[road[x.second][i].first],road[x.second][i].first}); } } } if(dist[c*W+d] <= K) { cout << "Yes" << endl; } else { cout << "No" << endl; } }