import Control.Monad

type Whites = [Coord]
type Coord  = (Int, Int)
type Mode   = Int

main :: IO ()
main = do
    [w,h,n] <- getInts
    xyas <- replicateM n getInts
    print $ whiteArea (w,h) xyas

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

whiteArea :: Coord -> [[Int]] -> Int
whiteArea (w,h) xyas = length $ paintAll whites paintInfos
  where
    whites     = [(x,y) | x <- [1..w], y <- [1..h]]
    paintInfos = [((xi,yi),ai) | [xi,yi,ai] <- xyas]

paintAll :: Whites -> [(Coord, Mode)] -> Whites
paintAll = foldr paint
  where
    paint ((xi,_),1) = filter (\(x,_) -> x >  xi)
    paint ((xi,_),2) = filter (\(x,_) -> x <= xi)
    paint ((_,yi),3) = filter (\(_,y) -> y >  yi)
    paint ((_,yi),4) = filter (\(_,y) -> y <= yi)