#include using namespace std; typedef pair, int> P; const int L = 55; char C[L][L]; bool ok[L][L][2510]; // x, y, snow int dx[4] = {-1, 1, 0, 0}; int dy[4] = {0, 0, -1, 1}; int h, w, a, b; int sx, sy, gx, gy; int main(){ cin.tie(nullptr); ios::sync_with_stdio(false); cin >> h >> w; cin >> a >> sx >> sy; cin >> b >> gx >> gy; for(int i = 0; i < h; i++){ for(int j = 0; j < w; j++){ cin >> C[i][j]; } } bool f = false; queue

q; q.push({{sx, sy}, a}); while(!q.empty()){ P p = q.front(); q.pop(); int x = p.first.first; int y = p.first.second; int snow = p.second; // cout << x << ' ' << y << ' ' << snow << endl; ok[x][y][snow] = true; if(x == gx and y == gy and snow == b){ break; } for(int i = 0; i < 4; i++){ int nx, ny; nx = dx[i] + x; ny = dy[i] + y; if(nx < 0 or ny < 0 or nx >= h or ny >= w){ continue; } int m = (C[nx][ny] == '*' ? 1 : -1) + snow; if(m <= 0 or m >= 2510 or m > b + h * w) continue; if(ok[nx][ny][m]) continue; q.push({{nx, ny}, m}); } } cout << (ok[gx][gy][b] ? "Yes" : "No") << endl; return 0; }