import  Data.List

main = do
    [w,h,n] <- map read . words <$> getLine
    xyas <- tuplify . map read . words <$> getContents
    print . count $ foldl' solve (0,0,w,h) xyas

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

solve (l,t,r,b) (x,_,1) = (max l x, t, r, b)
solve (l,t,r,b) (x,_,2) = (l, t, min r x, b)
solve (l,t,r,b) (_,y,3) = (l, max t y, r, b)
solve (l,t,r,b) (_,y,4) = (l, t, r, min b y)

tuplify [] = []
tuplify (x:y:a:xs) = (x,y,a):tuplify xs
