{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ w, h, n ] <- readInts
	queries <- replicateM n $ do
		[ x, y, a ] <- readInts
		return ( x, y, a )
	let	
		( x1, y1, x2, y2 ) = foldl solve ( 0, 0, w, h ) queries
	print $ ( max 0 $ x2 - x1 ) * ( max 0 $ y2 - y1 )

solve ( x1, y1, x2, y2 ) ( x, y, a )
	| a == 1 = ( ( max x1 x ), y1, x2, y2 )
	| a == 2 = ( x1, y1, ( min x2 x ), y2 )
	| a == 3 = ( x1, ( max y1 y ), x2, y2 )
	| a == 4 = ( x1, y1, x2, ( min y2 y ) )
