#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace std; typedef long long ll; const int DY[4] = {-1, 0, 0, 1}; const int DX[4] = { 0,-1, 1, 0}; struct Node { int y; int x; int val; Node(int y, int x, int val){ this->y = y; this->x = x; this->val = val; } }; int main(){ int h, w; cin >> h >> w; int a, sy, sx; cin >> a >> sy >> sx; int b, gy, gx; cin >> b >> gy >> gx; char field[h][w]; string line; for(int y = 0; y < h; y++){ cin >> line; for(int x = 0; x < w; x++){ field[y][x] = line[x]; } } queue que; que.push(Node(sy, sx, a)); bool checkList[h][w][2500]; memset(checkList, false, sizeof(checkList)); while(!que.empty()){ Node node = que.front(); que.pop(); int y = node.y; int x = node.x; int val = node.val; if(val == 0) continue; if(checkList[y][x][val]) continue; checkList[y][x][val] = true; if(val == b && y == gy && x == gx){ cout << "Yes" << endl; return 0; } for(int i = 0; i < 4; i++){ int ny = y + DY[i]; int nx = x + DX[i]; if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue; if(field[ny][nx] == '*'){ que.push(Node(ny, nx, val+1)); }else{ que.push(Node(ny, nx, val-1)); } } } cout << "No" << endl; return 0; }