open Scanf
open Printf
       
let _ =
  let w, h, n = scanf "%d %d %d\n" (fun x y z -> (x, y, z)) in
  let rec loop (lx, ly) (rx, ry) c =
    if c = 0 then (rx - lx) * (ry - ly)
    else
      match scanf "%d %d %d\n" (fun i j k -> (i, j, k)) with
        x, y, a when a = 1 -> loop (min rx (max x lx), ly) (rx, ry) (c-1)
      | x, y, a when a = 2 -> loop (lx, ly) (max lx (min x rx), ry) (c-1)
      | x, y, a when a = 3 -> loop (lx, min ry (max y ly)) (rx, ry) (c-1)
      | x, y, a -> loop (lx, ly) (rx, max ly (min y ry)) (c-1)
  in
  printf "%d\n" @@ loop (0, 0) (w, h) n
