// #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>; const ll MAX = 1e18; 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}}; bool fg = 0; vector cnt(h + 2, vector>(w + 2, {MAX, MAX, MAX, MAX, MAX})); cnt[xs][ys] = {0, 0, 0, 0, 0}; while (!dq.empty()) { auto fr = dq.front(); dq.pop_front(); v[fr[0]][fr[1]] = '*'; for (int i = 0; i < 4; i++) { int a = fr[0] + D[i][0]; int b = fr[1] + D[i][1]; if (v[a][b] == 'g') { fg = 1; cnt[a][b] = cnt[fr[0]][fr[1]]; if (i == 0) { cnt[a][b][0]++; } else if (i == 1) { cnt[a][b][1]++; } else if (i == 2) { cnt[a][b][2]++; } else { cnt[a][b][3]++; } break; } else if (v[a][b] == '.') { dq.push_front({a, b, 0}); cnt[a][b] = cnt[fr[0]][fr[1]]; if (i == 0) { cnt[a][b][0]++; } else if (i == 1) { cnt[a][b][1]++; } else if (i == 2) { cnt[a][b][2]++; } else { cnt[a][b][3]++; } } else if (v[a][b] == '@') { dq.push_back({a, b, 1}); cnt[a][b] = cnt[fr[0]][fr[1]]; cnt[a][b][4]++; if (i == 0) { cnt[a][b][0]++; } else if (i == 1) { cnt[a][b][1]++; } else if (i == 2) { cnt[a][b][2]++; } else { cnt[a][b][3]++; } } } } if (cnt[xt][yt][0] * u + cnt[xt][yt][1] * d + cnt[xt][yt][2] * r + cnt[xt][yt][3] * l + cnt[xt][yt][4] * p <= k) { cout << "Yes" << endl; } else { cout << "No" << endl; } return 0; }