#include #include #include #include #define repeat(i,n) for (int i = 0; (i) < (n); ++(i)) using namespace std; const int lim = 10000; const int dy[4] = { -1, 1, 0, 0 }; const int dx[4] = { 0, 0, 1, -1 }; int main() { int h, w; cin >> h >> w; int a, sy, sx; cin >> a >> sy >> sx; int b, gy, gx; cin >> b >> gy >> gx; vector m(h); repeat (y,h) cin >> m[y]; vector > > used(lim, vector >(h, vector(w))); queue > que; que.push(make_tuple(a, sy, sx)); used[a][sy][sx] = true; while (not que.empty()) { int c, y, x; tie(c, y, x) = que.front(); que.pop(); repeat (i,4) { int ny = y + dy[i]; int nx = x + dx[i]; if (0 <= ny and ny < h and 0 <= nx and nx < w) { int nc = c + (m[ny][nx] == '*' ? 1 : -1); if (1 <= nc and nc < lim) { if (not used[nc][ny][nx]) { used[nc][ny][nx] = true; que.push(make_tuple(nc, ny, nx)); } } } } } cout << (used[b][gy][gx] ? "Yes" : "No") << endl; return 0; }