main::IO()
main =do
  whn<-getLine
  let w:h:n:[] = map read (words whn)::[Int]
  dats<-getn n
  print (solver w h dats)

getn::Int -> IO [(Int,(Int,Int))]
getn 0 = return []
getn n = do
  xya<-getLine
  let x:y:a:[]= map read (words xya)::[Int]
  rest<-getn (n-1)
  return ((a,(x,y)):rest)

folding::(Int,Int,Int,Int)->[(Int,(Int,Int))]->(Int,Int,Int,Int)
folding (x1,x2,y1,y2) []                =(x1,x2,y1,y2)
folding (x1,x2,y1,y2) ((a,(x,y)):dats)
                      | a==1 = let x1'= max x1 x in folding (x1',x2,y1,y2) dats
                      | a==2 = let x2'= min x2 x in folding (x1,x2',y1,y2) dats
                      | a==3 = let y1'= max y1 y in folding (x1,x2,y1',y2) dats
                      | a==4 = let y2'= min y2 y in folding (x1,x2,y1,y2') dats

solver::Int -> Int -> [(Int,(Int,Int))]->Int
solver w h dats = let (x1,x2,y1,y2) = folding (0,w,0,h) dats in (max (x2-x1) 0)*(max (y2-y1) 0)