import Control.Monad
import Data.Bool
import Data.List
import Data.Maybe

main = sol <$> get >>= print

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

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

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

f Nothing _ = Nothing
f (Just (l,r,b,t)) [x,y,a]
  | a == 1    = bool Nothing (Just (max l x,r,b,t)) (x < r)
  | a == 2    = bool Nothing (Just (l,min r x,b,t)) (l < x)
  | a == 3    = bool Nothing (Just (l,r,max b y,t)) (y < t)
  | a == 4    = bool Nothing (Just (l,r,b,min t y)) (b < y)
  | otherwise = Nothing