import Control.Monad

main :: IO ()
main = do
  [w, h, n] <- readInts
  xyas <- replicateM n readInts
  print $ solve w h xyas

readInts :: IO [Int]
readInts = map read . words <$> getLine

solve :: Int -> Int -> [[Int]] -> Int
solve w h = go [ (x, y) | x <- [0..w], y <- [0..h] ]
  where
    go pts [] = length pts
    go pts ([xi, _, 1]:xyas) = go [ (x, y) | (x, y) <- pts, x >= xi ] xyas
    go pts ([xi, _, 2]:xyas) = go [ (x, y) | (x, y) <- pts, x <= xi ] xyas
    go pts ([_, yi, 3]:xyas) = go [ (x, y) | (x, y) <- pts, y >= yi ] xyas
    go pts ([_, yi, 4]:xyas) = go [ (x, y) | (x, y) <- pts, y <= yi ] xyas
