#![allow(unused_imports)] use std::cmp::*; use std::collections::*; use std::io::Write; use std::ops::Bound::*; #[allow(unused_macros)] macro_rules! debug { ($($e:expr),*) => { #[cfg(debug_assertions)] $({ let (e, mut err) = (stringify!($e), std::io::stderr()); writeln!(err, "{} = {:?}", e, $e).unwrap() })* }; } fn main() { let v = read_vec::(); let (h, w, k) = (v[0], v[1], v[2]); if k == 1 { println!("1"); return; } if h == 1 || w == 1 { assert!(false); } if k == 2 { let total = 2i64.pow((h * w) as u32) - 2; let raw_same = 2i64.pow(h as u32) - 2; let col_same = 2i64.pow(w as u32) - 2; let rc = raw_same + col_same; let ans = (total - rc) / (h * w) + raw_same / h + col_same / w; println!("{}", ans); return; } assert!(false); let total = 3i64.pow((h * w) as u32) - 3 * 2i64.pow((h * w) as u32) + 3; let raw_same = 3i64.pow(h as u32) - 3 * 2i64.pow(h as u32) + 3; let col_same = 3i64.pow(w as u32) - 3 * 2i64.pow(w as u32) + 3; let rc = raw_same + col_same; debug!(total, raw_same, col_same); let ans = (total - rc) / (h * w) + raw_same / h + col_same / w; println!("{}", ans); } fn read() -> T { let mut s = String::new(); std::io::stdin().read_line(&mut s).ok(); s.trim().parse().ok().unwrap() } fn read_vec() -> Vec { read::() .split_whitespace() .map(|e| e.parse().ok().unwrap()) .collect() }