#include #include using namespace std; using i64 = long long; class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x void debug(vector v, const char* sep) { const int n = v.size(); fprintf(stderr, "'"); for(int i=0; i void debug(vector v) { debug(v, " "); } template void debug(vector> v) { int n = v.size(); for(int i=0; i void debug(vector>> v) { int n = v.size(); for(int i=0; i void debug(vector>>> v) { int n = v.size(); for(int i=0; i void debug(vector>>>> v) { int n = v.size(); for(int i=0; i G; int a, b; int sr, sc, gr, gc; vector>> dp; vector dr = {0, 0, 1, -1}, dc = {1, -1, 0, 0}; int rec(int w, int r, int c) { int &res = dp[r][c][w]; if(res != -1) { return res; } if(w == b && r == gr && c == gc) { return res = 1; } res = 0; for(int i : range(dr.size())) { int nr = r + dr[i], nc = c + dc[i]; if(nr < 0 || R <= nr || nc < 0 || C <= nc) { continue; } int nw; if(G[nr][nc] == '.') { nw = w - 1; } else { nw = w + 1; } if(nw <= 0) { continue; } res |= rec(nw, nr, nc); } return res; } int main(void) { scanf("%d%d%d%d%d%d%d%d", &R, &C, &a, &sr, &sc, &b, &gr, &gc); G.resize(R); dp.assign(R, vector>(C, vector(4000, -1))); for(int r : range(R)) { cin >> G[r]; } bool ok = rec(a, sr, sc); puts(ok ? "Yes" : "No"); return 0; }