open Printf
open Scanf

let () =
  let (w,h,n) = scanf " %d %d %d" (fun w h n -> w,h,n) in
  let a = Array.init n (fun _ -> scanf " %d %d %d" (fun w h n -> w,h,n)) in
  let (min_x,min_y,max_x,max_y) =
    Array.fold_left (fun (x',y',x'',y'') (x,y,a) ->
        match a with
        | 1 -> (max x' x, y', x'', y'')
        | 2 -> (x', y', min x'' x, y'')
        | 3 -> (x', max y' y, x'', y'')
        | 4 -> (x', y', x'', min y'' y)
        | _ -> assert false
      ) (0,0,w,h) a in
  let dx = max_x - min_x in
  let dy = max_y - min_y in
  if dx >= 0 && dy >= 0
  then printf "%d\n" @@ dx*dy
  else printf "0\n"
