import Control.Monad (replicateM)

solve (a,b) (c,d) [] =
  if a < c && b < d
    then (c - a) * (d - b)
    else 0

solve (a,b) (c,d) ([x,y,a']:xss)
  | a' == 1 = solve (max a x,b) (c,d) xss
  | a' == 2 = solve (a,b) (min c x,d) xss
  | a' == 3 = solve (a,max b y) (c,d) xss
  | a' == 4 = solve (a,b) (c,min d y) xss

main = do
  [w,h,n] <- fmap read <$> words <$> getLine :: IO [Int]
  xss <- fmap (fmap read) <$> fmap words <$> replicateM n getLine :: IO [[Int]]
  putStrLn . show . solve (0,0) (w,h) $ xss
