#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i)) #define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i)) #define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i)) #if defined(_MSC_VER) || __cplusplus > 199711L #define aut(r,v) auto r = (v) #else #define aut(r,v) __typeof(v) r = (v) #endif #define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it) #define all(o) (o).begin(), (o).end() #define pb(x) push_back(x) #define mp(x,y) make_pair((x),(y)) #define mset(m,v) memset(m,v,sizeof(m)) #define INF 0x3f3f3f3f #define INFL 0x3f3f3f3f3f3f3f3fLL using namespace std; typedef vector vi; typedef pair pii; typedef vector > vpii; typedef long long ll; template inline void amin(T &x, U y) { if(y < x) x = y; } template inline void amax(T &x, U y) { if(x < y) x = y; } int main() { int H; int W; while(~scanf("%d%d", &H, &W)) { int A; int Si; int Sj; scanf("%d%d%d", &A, &Si, &Sj); int B; int Gi; int Gj; scanf("%d%d%d", &B, &Gi, &Gj); vector M(H); rep(i, H) cin >> M[i]; const int MaxX = max(A, B) + H * W * 2; vector vis((MaxX+1) * H * W); int inits = (A * H + Si) * W + Sj; vi stk; vis[inits] = true; stk.push_back(inits); bool ans = false; while(!stk.empty()) { int s = stk.back(); stk.pop_back(); int i = s / W % H, j = s % W, x = s / (H * W); if(x == B && i == Gi && j == Gj) { ans = true; break; } static const int dy[4] = {0, 1, 0, -1}, dx[4] = {1, 0, -1, 0}; rep(d, 4) { int yy = i + dy[d], xx = j + dx[d]; if(yy < 0 || yy >= H || xx < 0 || xx >= W) continue; int nx = x + (M[yy][xx] == '*' ? 1 : -1); if(nx <= 0 || nx > MaxX) continue; int ns = (nx * H + yy) * W + xx; if(vis[ns]) continue; vis[ns] = true; stk.push_back(ns); } } puts(ans ? "Yes" : "No"); } return 0; }