{-# LANGUAGE BangPatterns #-}

import Control.Monad
import Control.Monad.Trans.State.Strict
import Data.Char (isSpace)
import Data.Maybe (fromJust)
import qualified Data.ByteString.Lazy.Char8 as B
--
import qualified Data.List as L
import qualified Data.Vector.Unboxed as U

type Parser a = StateT B.ByteString Maybe a

parseInt :: Parser Int
parseInt = StateT (B.readInt . B.dropWhile isSpace)

parseInt3 :: Parser (Int,(Int,Int))
parseInt3 = do
    x<-parseInt
    y<-parseInt
    a<-parseInt
    return (a,(x,y))

parse :: Parser ((Int,Int), [(Int,(Int,Int))])
parse = do
    w<-parseInt
    h<-parseInt
    n<-parseInt
    liftM ((,) (w,h)) $ replicateM n parseInt3

main=do
    ((w,h),xyas) <- fromJust.evalStateT parse <$> B.getContents
    let l = maximum.(:) 0.map (fst.snd) $ filter((==1).fst)xyas
    let r = minimum.(:) w.map (fst.snd) $ filter((==2).fst)xyas
    let b = maximum.(:) 0.map (snd.snd) $ filter((==3).fst)xyas
    let t = minimum.(:) h.map (snd.snd) $ filter((==4).fst)xyas
    print $ (max 0 (r-l)) * (max 0 (t-b))