use std::io::{Read, Write}; struct Scanner { bytes: std::io::Bytes, buf: Vec } impl Scanner { fn new(r: R) -> Scanner { Scanner { bytes: r.bytes(), buf: Vec::new() } } fn next(&mut self) -> &str { self.buf = { self.bytes.by_ref().map(|b| b.unwrap()) .skip_while(|b| b.is_ascii_whitespace()) .take_while(|b| !b.is_ascii_whitespace()) .collect::>() }; unsafe { std::str::from_utf8_unchecked(&self.buf) } } } macro_rules! scan { ($sc:expr, [$t:tt; $n:expr]) => ( (0..$n).map(|_| scan!($sc, $t)).collect::>() ); ($sc:expr, ($($t:tt),*)) => (($(scan!($sc, $t)),*)); ($sc:expr, Usize1) => (scan!($sc, usize) - 1); ($sc:expr, Bytes) => ($sc.next().bytes().collect::>()); ($sc:expr, Chars) => ($sc.next().chars().collect::>()); ($sc:expr, $t:ty) => ($sc.next().parse::<$t>().unwrap()); } fn run(mut sc: Scanner, mut wr: W) { let (h, w, q) = scan!(sc, (usize, usize, usize)); let mut map = std::collections::BTreeMap::new(); let mut ans = h * w; for _ in 0..q { let (y, x) = scan!(sc, (Usize1, Usize1)); let value = map.entry(x).or_insert(h); if &y < value { ans -= *value - y; *value = y; } writeln!(wr, "{}", ans).ok(); } } fn main() { let (stdin, stdout) = (std::io::stdin(), std::io::stdout()); let sc = Scanner::new(std::io::BufReader::new(stdin.lock())); let wr = std::io::BufWriter::new(stdout.lock()); run(sc, wr); }