#include using namespace std; namespace { typedef double real; typedef long long ll; template ostream& operator<<(ostream& os, const vector& vs) { if (vs.empty()) return os << "[]"; os << "[" << vs[0]; for (int i = 1; i < vs.size(); i++) os << " " << vs[i]; return os << "]"; } template istream& operator>>(istream& is, vector& vs) { for (auto it = vs.begin(); it != vs.end(); it++) is >> *it; return is; } int H, W; int A, sy, sx; int B, gy, gx; vector F; void input() { cin >> H >> W; cin >> A >> sy >> sx; cin >> B >> gy >> gx; F.clear(); F.resize(H); cin >> F; } const int INF = 1<<28; struct S { int y, x, c; S(int y, int x, int c) : y(y), x(x), c(c) {} }; const int dy[] = {0, -1, 0, 1}; const int dx[] = {-1, 0, 1, 0}; const int MAX_H = 50; const int MAX_W = 50; void solve() { static bool D[MAX_H][MAX_W][4000]; memset(D, 0, sizeof(D)); queue Q; Q.push(S(sy, sx, A)); D[sy][sx][A] = 1; while (not Q.empty()) { S cur = Q.front(); Q.pop(); if (cur.y == gy && cur.x == gx && cur.c == B) { cout << "Yes" << endl; return; } for (int i = 0; i < 4; i++) { int ny = cur.y + dy[i]; int nx = cur.x + dx[i]; if (ny < 0 || ny >= H) continue; if (nx < 0 || nx >= W) continue; int nc = cur.c + (F[ny][nx] == '.' ? -1 : 1); if (nc <= 0) continue; if (nc >= 4000) continue; if (not D[ny][nx][nc]) { D[ny][nx][nc] = 1; Q.push(S(ny, nx, nc)); } } } cout << "No" << endl; } } int main() { input(); solve(); return 0; }