import Control.Monad

main :: IO ()
main = do
  [w, h, n] <- getInts
  inputs <- replicateM n getInts
  print $ solve (0, w) (0, h) inputs

getInts :: IO [Int]
getInts = map read . words <$> getLine

solve :: (Int, Int) -> (Int, Int) -> [[Int]] -> Int
solve (w1, w2) (h1, h2) []
  | w2 - w1 > 0 && h2 - h1 > 0 = (w2 - w1) * (h2 - h1)
  | otherwise = 0
solve (w1, w2) (h1, h2) (l:ls) = solve w' h' ls
  where
    (w', h') = update l
    update [x, y, a]
      | a == 1 = ((x, w2), (h1, h2))
      | a == 2 = ((w1, x), (h1, h2))
      | a == 3 = ((w1, w2), (y, h2))
      | a == 4 = ((w1, w2), (h1, y))
      | otherwise = ((0,0), (0,0))
