#include #include #include #include #include using namespace std; #define REP(i,s,e) for (i = s; i <= e; i++) #define rep(i,n) REP (i,0,(int)(n)-1) #define RREP(i,s,e) for (i = s; i >= e; i--) #define rrep(i,n) RREP (i,(int)(n)-1,0) #define INF (int)1e8 #define MOD (int)(1e9+7) typedef long long ll; bool arrive[50][50][1251]; int dxy[4] = {-1,0,1,0}; int main(void) { int i, j, h, w, a, b, si, sj, gi, gj; string m[50]; cin >> h >> w; cin >> a >> si >> sj; cin >> b >> gi >> gj; rep (i,h) cin >> m[i]; queue,int>> q; arrive[si][sj][a] = true; q.push(make_pair(make_pair(si,sj),a)); while (!q.empty()) { int x = q.front().first.first; int y = q.front().first.second; int size = q.front().second; q.pop(); rep (i,4) { int nx = x + dxy[i]; int ny = y + dxy[(i+1)%4]; if (nx < 0 || nx >= h || ny < 0 || ny >= w) continue; int nsize = size + (m[nx][ny] == '*' ? 1 : -1); if (nsize > 0 && nsize <= 1250 && !arrive[nx][ny][nsize]) { arrive[nx][ny][nsize] = true; q.push(make_pair(make_pair(nx,ny),nsize)); } } } if (arrive[gi][gj][b]) cout << "Yes" << endl; else cout << "No" << endl; return 0; }