
import System.IO
import Control.Applicative ((<$>))


main = do
  l1 <- getLine
  let (width:height:num:_) = (\x -> read x :: Int) <$> words l1
  ((xO,xW),(yO,yH)) <- goc num (0, width) (0, height)
  putStrLn $ show $ (max 0 (xW - xO)) * (max 0 (yH - yO))


goc :: Int -> (Int,Int) -> (Int,Int) -> IO ((Int,Int), (Int,Int))
goc 0 xL yL = return (xL, yL)
goc n xL@(xO,xW) yL@(yO,yH) = do
  l <- getLine
  let (x:y:a:_) = (\x -> read x :: Int) <$> words l
  next a x y
  where
    next 1 x _ = goc (n - 1) (max xO x, xW) yL
    next 2 x _ = goc (n - 1) (xO, min xW x) yL
    next 3 _ y = goc (n - 1) xL (max yO y, yH)
    next 4 _ y = goc (n - 1) xL (yO, min yH y)
