let func w h n =
  let rec f xl xr yl yr cnt =
    if cnt == n then (xl, xr, yl, yr)
    else
      let x, y, a = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c)
      in
      match a with
    | 1 -> f (max xl x) xr yl yr (cnt+1)
    | 2 -> f xl (min xr x) yl yr (cnt+1)
    | 3 -> f xl xr (max y yl) yr (cnt+1)
    | 4 -> f xl xr yl (min y yr) (cnt+1)
    | _ -> raise @@ Sys_error "error"
  in f 0 w 0 h 0

let calc (xl, xr, yl, yr) =
  if xl > xr || yl > yr then 0
  else (xr - xl) * (yr - yl)

let () =
  let w, h, n = Scanf.scanf "%d %d %d\n" (fun a b c -> a, b, c)
  in func w h n
  |> calc
  |> print_int
  |> print_newline
