use std::{collections::BinaryHeap, cmp::Reverse}; const DX: [isize; 4] = [-1, 1, 0, 0]; const DY: [isize; 4] = [0, 0, -1, 1]; fn main() { let mut hwyx = String::new(); std::io::stdin().read_line(&mut hwyx).ok(); let hwyx: Vec = hwyx.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); let h = hwyx[0]; let w = hwyx[1]; let x = hwyx[2]-1; let y = hwyx[3]-1; let grid = (0..h).map(|_| { let mut temp = String::new(); std::io::stdin().read_line(&mut temp).ok(); let temp: Vec = temp.trim().split_whitespace().map(|s| s.parse().unwrap()).collect(); temp }) .collect::>>(); let mut checked = vec![vec![false; w]; h]; checked[x][y] = true; let mut frontier = BinaryHeap::new(); let mut player_attack = grid[x][y]; for dir in 0..4 { let nx = x as isize + DX[dir]; let ny = y as isize + DY[dir]; if nx >= 0 && ny >= 0 && nx < h as isize && ny < w as isize { let nx = nx as usize; let ny = ny as usize; if checked[nx][ny] { continue; } checked[nx][ny] = true; frontier.push((Reverse(grid[nx][ny]), (nx, ny))); } } while let Some((Reverse(attack), (cx, cy))) = frontier.pop() { if attack >= player_attack { println!("No"); return; } player_attack += attack; for dir in 0..4 { let nx = cx as isize + DX[dir]; let ny = cy as isize + DY[dir]; if nx >= 0 && ny >= 0 && nx < h as isize && ny < w as isize { let nx = nx as usize; let ny = ny as usize; if checked[nx][ny] { continue; } checked[nx][ny] = true; frontier.push((Reverse(grid[nx][ny]), (nx, ny))); } } } println!("Yes"); }