#include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int DY[4] = {-1, 0, 1, 0}; const int DX[4] = {0, 1, 0, -1}; struct Node { int y; int x; ll cost; Node(int y = -1, int x = -1, ll cost = -1) { this->y = y; this->x = x; this->cost = cost; } bool operator>(const Node &n) const { return cost > n.cost; } }; int main() { int H, W; cin >> H >> W; ll U, D, R, L, K, P; cin >> U >> D >> R >> L >> K >> P; int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty; char C[H + 1][W + 1]; for (int y = 1; y <= H; ++y) { for (int x = 1; x <= W; ++x) { cin >> C[y][x]; } } priority_queue , greater> pque; pque.push(Node(sy, sx, 0)); bool visited[H + 1][W + 1]; memset(visited, false, sizeof(visited)); while (not pque.empty()) { Node node = pque.top(); pque.pop(); if (node.cost > K) continue; if (visited[node.y][node.x]) continue; visited[node.y][node.x] = true; if (node.y == ty && node.x == tx) { cout << "Yes" << endl; return 0; } for (int direct = 0; direct < 4; ++direct) { int ny = node.y + DY[direct]; int nx = node.x + DX[direct]; if (ny <= 0 || nx <= 0 || H < ny || W < nx) continue; if (C[ny][nx] == '#') continue; ll ncost = node.cost; if (C[ny][nx] == '@') ncost += P; if (direct == 0) ncost += U; if (direct == 1) ncost += R; if (direct == 2) ncost += D; if (direct == 3) ncost += L; pque.push(Node(ny, nx, ncost)); } } cout << "No" << endl; return 0; }