#include using namespace std; int h, w; long long k, p, xs, ys, xt, yt; int d[4], dx[4] = { -1, 1, 0, 0 }, dy[4] = { 0, 0, 1, -1 }; string s[100]; typedef pair> P; priority_queue, greater

> Q; bool f; int main() { cin >> h >> w >> d[0] >> d[1] >> d[2] >> d[3] >> k >> p >> xs >> ys >> xt >> yt; for (int i = 0; i < h; i++) cin >> s[i]; xs--; ys--; xt--; yt--; Q.push({ 0, {xs, ys} }); while (!Q.empty()) { long long c = Q.top().first, z; int xn = Q.top().second.first, yn = Q.top().second.second; Q.pop(); for (int i = 0; i < 4; i++) { if ((i == 0 && xn > 0) || (i == 1 && xn < h - 1) || (i == 2 && yn < w - 1) || (i == 3 && yn > 0)) { int xk = xn + dx[i], yk = yn + dy[i]; if (s[xk][yk] != '#') { z = d[i]; if (s[xk][yk] == '@') z += p; if (c + z <= k) { if (xk == xt && yk == yt) { f = 1; break; } s[xk][yk] = '#'; Q.push({ c + z, {xk, yk} }); } } } } if (f) break; } if(f) cout << "Yes" << endl; else cout << "No" << endl; }