use std::io::Read; fn main() { let mut s = String::new(); std::io::stdin().read_to_string(&mut s).ok(); let mut s = s.trim().split_whitespace(); let h: usize = s.next().unwrap().parse().unwrap(); let w: usize = s.next().unwrap().parse().unwrap(); let mut a: Vec = s.map(|e| e.parse().unwrap()).collect(); a.sort(); let mut ans = String::new(); for i in 0..h * w { ans += &a[i].to_string(); if (i + 1) % w != 0 { ans += " "; } if (i + 1) % w == 0 { ans += "\n"; } } print!("{}", ans); }