use std::collections::VecDeque; macro_rules! get { ($t:ty) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.trim().parse::<$t>().unwrap() } }; ($($t:ty),*) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); let mut iter = line.split_whitespace(); ( $(iter.next().unwrap().parse::<$t>().unwrap(),)* ) } }; ($t:ty; $n:expr) => { (0..$n).map(|_| get!($t) ).collect::>() }; ($($t:ty),*; $n:expr) => { (0..$n).map(|_| get!($($t),*) ).collect::>() }; ($t:ty ;;) => { { let mut line: String = String::new(); std::io::stdin().read_line(&mut line).unwrap(); line.split_whitespace() .map(|t| t.parse::<$t>().unwrap()) .collect::>() } }; ($t:ty ;; $n:expr) => { (0..$n).map(|_| get!($t ;;)).collect::>() }; } fn main() { let (height, width) = get!(usize, usize); let mut queue = VecDeque::new(); for i in 0..(height * width) { queue.push_back(i + 1); } let mut matrix = vec![vec![0; width]; height]; for row in 0..height { for col in 0..width { if (row + col) % 2 == 0 { matrix[row][col] = queue.pop_front().unwrap(); } else { matrix[row][col] = queue.pop_back().unwrap(); } } } let sum = matrix[0][0] + matrix[0][1] + matrix[1][0] + matrix[1][1]; for row in 0..(height - 1) { for col in 0..(width - 1) { let mut s = 0; for dr in 0..2 { for dc in 0..2 { s += matrix[row + dr][col + dc]; } } if s != sum { println!("No"); return; } } } println!("Yes"); for row in 0..height { print!("{}", matrix[row][0]); for col in 1..width { print!(" {}", matrix[row][col]); } println!(); } }