main = do
  [w,h,n] <- map read . words <$> getLine :: IO [Int]
  input <- map (map read . words) . lines <$> getContents :: IO [[Int]]
  let (l, r, b, t) = solve (0, w, 0, h) input
  print $ (r - l) * (t - b)

solve :: (Int, Int, Int, Int) -> [[Int]] -> (Int, Int, Int, Int)
solve (l, r, t, b) [] = (l, r, t, b)
solve (l, r, t, b) ([x, y, a]:s)
  | a == 1 && l < x = solve (x, r, b, t) s
  | a == 2 && x < r = solve (l, x, b, t) s
  | a == 3 && b < y = solve (l, r, x, t) s
  | a == 4 && y < t = solve (l, r, b, x) s
  | otherwise       = solve (l, r, b, t) s
