import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    [w,h,n] <- getIntList
    axys <- replicateM n $ do
        [x,y,a] <- getIntList
        return (a,x,y)
    print $ solve axys (0,w,0,h)

solve [] (s1,s2,s3,s4) = (max 0 (s2-s1)) * (max 0 (s4-s3))
solve ((a,x,y):axys) (s1,s2,s3,s4)
    | a == 1 = let s1' = max s1 x in solve axys (s1',s2,s3,s4)
    | a == 2 = let s2' = min s2 x in solve axys (s1,s2',s3,s4)
    | a == 3 = let s3' = max s3 y in solve axys (s1,s2,s3',s4)
    | a == 4 = let s4' = min s4 y in solve axys (s1,s2,s3,s4')