solve :: [(Int, Int, Int)] -> (Int, Int) -> (Int, Int) -> Int
solve [] (ox, oy) (dx, dy) = w * h
  where w = max 0 $ dx - ox
        h = max 0 $ dy - oy
solve ((x, y, a):xs) (ox, oy) (dx, dy)
  | a == 1 = solve xs (max x ox, oy) (dx, dy)
  | a == 2 = solve xs (ox, oy) (min x dx, dy)
  | a == 3 = solve xs (ox, max y oy) (dx, dy)
  | a == 4 = solve xs (ox, oy) (dx, min y dy)

main :: IO ()
main = do
  [w, h, n] <- map read . words <$> getLine
  let toTuple [x, y, a] = (x, y, a)
  xyas <- map (toTuple . map read . words) . lines <$> getContents
  print $ solve xyas (0, 0) (w, h)