import Control.Monad

fill [x, _, 1] (xl, xr, yb, yt) = (max x xl, xr, yb, yt)
fill [x, _, 2] (xl, xr, yb, yt) = (xl, min x xr, yb, yt)
fill [_, y, 3] (xl, xr, yb, yt) = (xl, xr, max y yb, yt)
fill [_, y, 4] (xl, xr, yb, yt) = (xl, xr, yb, min y yt)

calc (xl, xr, yb, yt) = max 0 (xr-xl) * max 0 (yt-yb)


main = map read . words <$> getLine >>= \[w,h,n] -> (replicateM n (fill . map read . words <$> getLine) >>= print . calc . foldr ($) (0, w, 0, h))