#include void input(std::string f) { std::string one = f + ".in"; std::string two = f + ".out"; freopen(one.c_str(), "r", stdin); freopen(two.c_str(), "w", stdout); } const int N = 1007; bool board[N][N]; bool used[N][N]; int score[N][N]; int n, k; bool valid_f(std::pair p) { if(p.first < 1 || p.first > n || p.second < 1 || p.second > n) return false; return !board[p.first][p.second]; } int main () { std::ios::sync_with_stdio(false); std::cin.tie(NULL); input("chess"); std::pair p1, p2; std::cin >> n >> k >> p1.first >> p1.second >> p2.first >> p2.second; for(int i = 1; i <= n; i++) for(int j = 1; j <= n; j++) std::cin >> board[i][j]; std::queue > q; q.push(p1); used[p1.first][p1.second] = true; score[p1.first][p1.second] = 0; while(!q.empty()) { std::pair p = q.front(); q.pop(); if(p == p2) break; std::pair to; for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) { to.first = p.first + (i ? 1 : -1) * 2; to.second = p.second + (j ? 1 : -1) * 1; if(valid_f(to) && !used[to.first][to.second]) { used[to.first][to.second] = true; score[to.first][to.second] = score[p.first][p.second] + 1; q.push(to); } } for(int i = 0; i < 2; i++) for(int j = 0; j < 2; j++) { to.first = p.first + (i ? 1 : -1) * 1; to.second = p.second + (j ? 1 : -1) * 2; if(valid_f(to) && !used[to.first][to.second]) { used[to.first][to.second] = true; score[to.first][to.second] = score[p.first][p.second] + 1; q.push(to); } } } //std::cout << score[p2.first][p2.second] << "\n"; if(score[p2.first][p2.second] <= k && k % 2 == score[p2.first][p2.second] % 2) std::cout << "Yes\n"; else std::cout << "No\n"; return 0; }