#include using namespace std; const int ds[] = {-1, 0, 1, 0, -1}; const string output[] = {"Queen can not escape and Army can not catch Queen.", "Queen can escape.", "Army can catch Queen."}; void solve() { int H, W; cin >> H >> W; if (H * W > 1000) { exit(1); } // m = 0: queen moves first. m = 1: army moves first. auto id = [&](int qi, int qj, int ai, int aj, int m) -> int { return ((W * qi + qj) * H * W + (W * ai + aj)) * 2 + m; }; auto id_inv = [&](int t) -> tuple { int m = t % 2; t /= 2; int q = t / (H * W); int a = t % (H * W); int qi = q / W; int qj = q % W; int ai = a / W; int aj = a % W; return {qi, qj, ai, aj, m}; }; int N = H * W * H * W * 2; vector> adj_inv(N); vector deg(N); vector answer(N); // 1: Yes, 0: No. queue q; for (int qi = 0; qi < H; qi++) { for (int qj = 0; qj < W; qj++) { for (int ai = 0; ai < H; ai++) { for (int aj = 0; aj < W; aj++) { for (int m = 0; m < 2; m++) { int t = id(qi, qj, ai, aj, m); if (qi == ai && qj == aj) { answer[t] = 1; q.push(t); } int nm = m ^ 1; if (nm == 0) { for (int i = 0; i < 4; i++) { int di = ds[i]; int dj = ds[i + 1]; int nqi = qi + di; int nqj = qj + dj; if (0 <= nqi && nqi < H && 0 <= nqj && nqj < W) { int nt = id(nqi, nqj, ai, aj, nm); adj_inv[t].push_back(nt); deg[nt]++; } } } else { for (int i = 0; i < 4; i++) { int di = ds[i]; int dj = ds[i + 1]; int nai = ai + di; int naj = aj + dj; if (0 <= nai && nai < H && 0 <= naj && naj < W) { int nt = id(qi, qj, nai, naj, nm); adj_inv[t].push_back(nt); deg[nt]++; } } } } } } } } while (!q.empty()) { int t = q.front(); int m = t % 2; q.pop(); // auto [e1, e2, e3, e4, e5] = id_inv(t); // cerr << t << ' ' << e1 << ' ' << e2 << ' ' << e3 << ' ' << e4 << ' ' // << e5 << ' ' << answer[t] << endl; for (auto &&nt : adj_inv[t]) { if (answer[nt] == 0) { // cerr << nt << endl; deg[nt]--; if (m == 1) { if (answer[t] == 0) { answer[nt] = 0; q.push(nt); } else if (answer[t] == 1 && deg[nt] == 0) { answer[nt] = 1; q.push(nt); } } else { if (answer[t] == 1) { answer[nt] = 1; q.push(nt); } else if (answer[t] == 0 && deg[nt] == 0) { answer[nt] = 0; q.push(nt); } } } } } int sqi, sqj, sai, saj; cin >> sai >> saj; cin >> sqi >> sqj; sai--; saj--; sqi--; sqj--; cout << (answer[id(sqi, sqj, sai, saj, 1)] ? "Yes" : "No") << endl; return; } int main() { solve(); }