main :: IO ()
main = do
  [w,h,n] <- map read . words <$> getLine :: IO [Int]
  ptAnda <- getInfo n
  let rest = delete ptAnda (getPos w h)
  print $ area rest

type Pos = (Int, Int)
type PtAndA = [Int]

getInfo :: Int -> IO [PtAndA]
getInfo n = sequenceA (replicate n (map read . words <$> getLine))

getPos :: Int -> Int -> [Pos]
getPos w h = [(x, y) | x <- [0..w], y <- [0..h]]

delete :: [PtAndA] -> [Pos] -> [Pos]
delete [] pos = pos
delete (p:ps) pos
  |last p == 1 = delete ps (filter (\t -> not (fst t < x)) pos) 
  |last p == 2 = delete ps (filter (\t -> not (fst t > x)) pos) 
  |last p == 3 = delete ps (filter (\t -> not (snd t < y)) pos) 
  |otherwise   = delete ps (filter (\t -> not (snd t > y)) pos)
  where x = head p
        y = p !! 1 

area :: [Pos] -> Int
area [] = 0
area xs = (x2-x1) * (y2-y1)
  where x2 = foldl (\x n -> if x >= fst n then x else fst n) (fst $ head xs) xs
        x1 = foldl (\x n -> if x <= fst n then x else fst n) (fst $ head xs) xs
        y2 = foldl (\y n -> if y >= snd n then y else fst n) (snd $ head xs) xs
        y1 = foldl (\y n -> if y <= snd n then y else fst n) (snd $ head xs) xs
  
