// #define _GLIBCXX_DEBUG #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; using ll = long long; using ld = long double; using P = pair; // #include // using namespace atcoder; // using mint = modint1000000007; // #include // #include // namespace mp = boost::multiprecision; // using Bint = mp::cpp_int; // using Bdouble = mp::number>; int main() { cin.tie(nullptr); ios_base::sync_with_stdio(false); int h, w; cin >> h >> w; vector v(h + 2, vector(w + 2, '#')); ll u, d, r, l, k, p; cin >> u >> d >> r >> l >> k >> p; int xs, ys, xt, yt; cin >> xs >> ys >> xt >> yt; for (int i = 1; i < h + 1; i++) { for (int j = 1; j < w + 1; j++) { cin >> v[i][j]; } } deque> dq; v[xt][yt] = 'g'; dq.push_back({xs, ys, 0}); vector D[4] = {{-1, 0}, {1, 0}, {0, 1}, {0, -1}}; ll cost = 0; bool fg = 0; while (!dq.empty()) { auto fr = dq.front(); dq.pop_front(); v[fr[0]][fr[1]] = '*'; if (fr[2] == 1) { cost += p; } for (int i = 0; i < 4; i++) { if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == 'g') { fg = 1; break; } else if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == '.') { dq.push_front({fr[0] + D[i][0], fr[1] + D[i][1], 0}); } else if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == '@') { dq.push_back({fr[0] + D[i][0], fr[1] + D[i][1], 1}); } } } if (!fg) { cout << "No" << endl; return 0; } queue> que; que.push({xs, ys}); while (!que.empty()) { auto fr = que.front(); que.pop(); v[fr[0]][fr[1]] = '+'; for (int i = 0; i < 4; i++) { if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == 'g') { if (i == 0) { cost += u; } else if (i == 1) { cost += d; } else if (i == 2) { cost += r; } else { cost += l; } break; } else if (v[fr[0] + D[i][0]][fr[1] + D[i][1]] == '*') { if (i == 0) { cost += u; } else if (i == 1) { cost += d; } else if (i == 2) { cost += r; } else { cost += l; } que.push({fr[0] + D[i][0], fr[1] + D[i][1]}); } } } if (cost <= k) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }