#include using namespace std; vector dy = {1, 0, -1, 0}; vector dx = {0, 1, 0, -1}; int main(){ int H, W; cin >> H >> W; int A, Si, Sj; cin >> A >> Si >> Sj; int B, Gi, Gj; cin >> B >> Gi >> Gj; vector M(H); for (int i = 0; i < H; i++){ cin >> M[i]; } vector>> used(H, vector>(W, vector(1200, false))); used[Si][Sj][A] = true; queue> Q; Q.push(make_tuple(Si, Sj, A)); while (!Q.empty()){ int y = get<0>(Q.front()); int x = get<1>(Q.front()); int s = get<2>(Q.front()); Q.pop(); for (int i = 0; i < 4; i++){ int y2 = y + dy[i]; int x2 = x + dx[i]; if (0 <= y2 && y2 < H && 0 <= x2 && x2 < W){ int s2 = s; if (M[y2][x2] == '*'){ s2++; } else { s2--; } if (1 <= s2 && s2 < 1200){ if (!used[y2][x2][s2]){ used[y2][x2][s2] = true; Q.push(make_tuple(y2, x2, s2)); } } } } } if (used[Gi][Gj][B]){ cout << "Yes" << endl; } else { cout << "No" << endl; } }