mod io { #[macro_export] macro_rules! scan { ($r:expr, [$t:tt; $n:expr]) => ((0..$n).map(|_| scan!($r, $t)).collect::>()); ($r:expr, ($($t:tt),*)) => (($(scan!($r, $t)),*)); ($r:expr, [u8]) => (io::scan($r)); ($r:expr, String) => (io::scan($r).into_iter().map(char::from).collect::()); ($r:expr, $t:ty) => (scan!($r, String).parse::<$t>().unwrap()); } pub fn scan(r: &mut R) -> Vec { let mut res = Vec::new(); loop { let buf = match r.fill_buf() { Ok(buf) => buf, Err(e) if e.kind() == std::io::ErrorKind::Interrupted => continue, Err(e) => panic!(e), }; let (done, used) = match buf.iter().position(u8::is_ascii_whitespace) { Some(i) => { res.extend_from_slice(&buf[..i]); (res.len() > 0, i + 1) } None => { res.extend_from_slice(buf); (buf.is_empty(), buf.len()) } }; r.consume(used); if done { return res; } } } } fn run(reader: &mut R, writer: &mut W) { let (w, h, x) = scan!(reader, (usize, usize, usize)); if h == 1 && w == 1 && x > 9 || (h == 1 || w == 1) && x > 18 || x > 36 { writer.write_all(b"-1\n").ok(); return; }; if x > 9 && (w % 3 != 2 && h % 3 != 2) { writer.write_all(b"-1\n").ok(); return; } if x > 18 && (w % 3 != 2 || h % 3 != 2) { writer.write_all(b"-1\n").ok(); return; } let mut ans = vec![vec![b'0'; w]; h]; let si = if h % 3 == 0 { 1 } else { 0 }; let sj = if w % 3 == 0 { 1 } else { 0 }; for i in (si..h).step_by(3) { for j in (sj..w).step_by(3) { let mut x = x; for p in i..(h.min(i + if h % 3 == 2 { 2 } else { 1 })) { for q in j..(w.min(j + if w % 3 == 2 { 2 } else { 1 })) { let v = x.min(9); x -= v; ans[p][q] = b'0' + v as u8; } } } } for ans in ans { writer.write_all(&ans).ok(); writer.write_all(b"\n").ok(); } } fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let mut reader = std::io::BufReader::new(stdin.lock()); let mut writer = std::io::BufWriter::new(stdout.lock()); run(&mut reader, &mut writer); }