{-# LANGUAGE MultiWayIf #-}

import Control.Monad
import Data.Maybe (fromJust)
import qualified Data.ByteString.Char8 as B
import Data.IORef

main :: IO ()
main = do
    [w, h, n] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
    x1 <- newIORef 0
    x2 <- newIORef w
    y3 <- newIORef 0
    y4 <- newIORef h
    replicateM_ n $ do
        [x, y, a] <- map (fst . fromJust . B.readInt) . B.words <$> B.getLine :: IO [Int]
        xx1 <- readIORef x1
        xx2 <- readIORef x2
        yy3 <- readIORef y3
        yy4 <- readIORef y4
        if  | a == 1 -> writeIORef x1 (max xx1 x)
            | a == 2 -> writeIORef x2 (min xx2 x)
            | a == 3 -> writeIORef y3 (max yy3 y)
            | a == 4 -> writeIORef y4 (min yy4 y)
    xxx1 <- readIORef x1
    xxx2 <- readIORef x2
    yyy3 <- readIORef y3
    yyy4 <- readIORef y4
    print $ max 0 (xxx2 - xxx1) * max 0 (yyy4 - yyy3)
