import Control.Applicative
import Control.Monad
import Data.List
import Data.Ord (comparing)

fst3 (a, _, _) = a
snd3 (_, b, _) = b
trd3 (_, _, c) = c

main :: IO ()
main = do
    [w, h, n] <- fmap read . words <$> getLine :: IO [Int]
    xyas <- replicateM n $ do
        [x, y, a] <- fmap read . words <$> getLine :: IO [Int]
        return (x, y, a)

    let x1 = case filter ((== 1) . trd3) xyas of
            [] -> 0
            xs -> fst3 $ maximumBy (comparing fst3) xs
    let x2 = case filter ((== 2) . trd3) xyas of
            [] -> w
            xs -> fst3 $ minimumBy (comparing fst3) xs
    let y1 = case filter ((== 3) . trd3) xyas of
            [] -> 0
            xs -> snd3 $ maximumBy (comparing snd3) xs
    let y2 = case filter ((== 4) . trd3) xyas of
            [] -> h
            xs -> snd3 $ maximumBy (comparing snd3) xs
    print $ max (x2 - x1) 0 * max (y2 - y1) 0