main = do
 [w,h,_] <- map read . words <$> getLine
 xyas <- map (map read . words) . lines <$> getContents
 let (xs,ys) = foldr paint ([1..w],[1..h]) xyas
 print (length xs * length ys)

paint [x,_,1] (xs,ys) = (dropWhile (<=x) xs, ys)
paint [x,_,2] (xs,ys) = (takeWhile (<=x) xs, ys)
paint [_,y,3] (xs,ys) = (xs, dropWhile (<=y) ys)
paint [_,y,4] (xs,ys) = (xs, takeWhile (<=y) ys)