import           Control.Monad
import           Data.Array.IO
import           Data.List.Split
import           Data.List
import           Data.Ord

type Index = (Int, Int)
type Ret = IOUArray Index Int

main :: IO ()
main = do
  [w, h, n] <- map read . words <$> getLine
  ipt       <- replicateM n $ map read . words <$> getLine
  ret       <- newArray ((0, 0), (w - 1, h - 1)) 1 :: IO Ret

  forM_ ipt $ \(x : y : a : _) -> case a of
    1 -> mapM_ (\i -> writeArray ret i 0)
               [ (a, b) | a <- [0 .. x - 1], b <- [0 .. h - 1] ]
    2 -> mapM_ (\i -> writeArray ret i 0)
               [ (a, b) | a <- [x .. w - 1], b <- [0 .. h - 1] ]
    3 -> mapM_ (\i -> writeArray ret i 0)
               [ (a, b) | a <- [0 .. w - 1], b <- [0 .. y - 1] ]
    4 -> mapM_ (\i -> writeArray ret i 0)
               [ (a, b) | a <- [0 .. w - 1], b <- [y .. h - 1] ]
    _ -> return ()

  print =<< sum <$> mapM (readArray ret)
                         [ (a, b) | a <- [0 .. w - 1], b <- [0 .. h - 1] ]

