#include #include #include #include #include using namespace std; #define rep(i,n) for(int i=0;i<(n);i++) int dx[4] = {1, 0, 0, -1}; int dy[4] = {0, 1, -1, 0}; int h, w; int a, si, sj; int b, gi, gj; string s[51]; bool board[51][51][51]; struct t{ int size, y, x; t(int size, int y, int x) : size(size), y(y), x(x) {} }; int main(void){ cin >> h >> w; cin >> a >> si >> sj; cin >> b >> gi >> gj; rep(i, h) cin >> s[i]; queue q; q.push(t(a, si, sj)); board[a][si][sj] = true; while(!q.empty()){ t now = q.front(); q.pop(); for (int i = 0; i < 4; ++i){ if(0 <= now.y + dy[i] && now.y + dy[i] < h && 0 <= now.x + dx[i] && now.x + dx[i] < w){ if(s[now.y + dy[i]][now.x + dx[i]] == '*'){ if(now.size <= 49 && board[now.size + 1][now.y + dy[i]][now.x + dx[i]] == false){ board[now.size + 1][now.y + dy[i]][now.x + dx[i]] = true; q.push(t(now.size + 1, now.y + dy[i], now.x + dx[i])); } }else{ if(2 <= now.size && board[now.size - 1][now.y + dy[i]][now.x + dx[i]] == false){ board[now.size - 1][now.y + dy[i]][now.x + dx[i]] = true; q.push(t(now.size - 1, now.y + dy[i], now.x + dx[i])); } } } } } if(board[b][gi][gj]) printf("Yes\n"); else printf("No\n"); return 0; }