import Control.Monad
import Data.List

main = sol <$> get >>= print

get = map (map read . words) . lines <$> getContents

sol ([w,h,_]:ps) = area $ foldl' f (0,w,0,h) ps

area (l,r,b,t) = max 0 (r-l)*max 0 (t-b)

f (l,r,b,t) [x,y,a]
  | a == 1    = (max l x,r,b,t)
  | a == 2    = (l,min r x,b,t)
  | a == 3    = (l,r,max b y,t)
  | a == 4    = (l,r,b,min t y)
  | otherwise = undefined