{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine


main = do
  [w, h, n] <- readIntList
  arr <- forM [1..n] (const readIntList)
  let (lx, ux, ly, uy) = foldl' update (0, w, 0, h) arr
  print $ (max (ux - lx) 0) * (max (uy - ly) 0)

update (lx, ux, ly, uy) [x, y, a]
  | a == 1 = (max x lx, ux, ly, uy)
  | a == 2 = (lx, min x ux, ly, uy)
  | a == 3 = (lx, ux, max y ly, uy)
  | a == 4 = (lx, ux, ly, min y uy)
