/** * @FileName a.cpp * @Author kanpurin * @Created 2020.06.01 14:30:01 **/ #include "bits/stdc++.h" using namespace std; typedef long long ll; int main() { int h,w;cin >> h >> w; int a,sx,sy;cin >> a >> sx >> sy; int b,gx,gy;cin >> b >> gx >> gy; vector g(h); for (int i = 0; i < h; i++) { cin >> g[i]; } const int dx[] = {0,1,0,-1}, dy[] = {1,0,-1,0}; int lim = max(a,b)+h*w; vector>> visited(h,vector>(w,vector(lim + 1,false))); queue> que; que.push(make_tuple(sx,sy,a)); while(!que.empty()) { auto p = que.front(); que.pop(); int nx = get<0>(p); int ny = get<1>(p); int sz = get<2>(p); for (int k = 0; k < 4; k++) { int x = nx + dx[k], y = ny + dy[k]; if (x >= 0 && x < h && y >= 0 && y < w) { if (g[x][y] == '.') { if (sz-1 >= 1 && !visited[x][y][sz-1]) { visited[x][y][sz-1] = true; que.push(make_tuple(x,y,sz-1)); } } else { if (sz+1 <= lim && !visited[x][y][sz+1]) { visited[x][y][sz+1] = true; que.push(make_tuple(x,y,sz+1)); } } } } } if (visited[gx][gy][b]) { puts("Yes"); } else { puts("No"); } return 0; }