main :: IO ()
main = do
  [w,h,n] <- map read . words <$> getLine :: IO [Int]
  solve 0 w 0 h n

-- solve :: (Eq a, Num a) => Int -> Int -> Int -> Int -> a -> IO ()
solve miX maX miY maY 0 = do print $ if res miX maX miY maY < 0 then 0 else res miX maX miY maY
solve miX maX miY maY n = do
  [x,y,a] <- map read . words <$> getLine :: IO [Int]
  case a of
    1 -> solve (max x maX) maX miY maY (n-1)
    2 -> solve miX (min x miX) miY maY (n-1)
    3 -> solve miX maX (max y maY) maY (n-1)
    4 -> solve miX maX miY (min y miY) (n-1)

res :: Int -> Int -> Int -> Int -> Int
res miX maX miY maY = (maX - miX) * (maY - miY)
