main :: IO ()
main = do
  [w,h,n] <- map read . words <$> getLine :: IO [Int]
  pta <- getInfo n
  let (s,e) = overwrite pta ((0,0), (w,h))
  print $ area s e

type Pos = (Int, Int)
type Pta = [Int]

getInfo :: Int -> IO [Pta]
getInfo n = sequenceA (replicate n (map read . words <$> getLine))

overwrite :: [Pta] -> (Pos, Pos) -> (Pos, Pos)
overwrite [] (start, end) = (start,end)
overwrite (x:xs) (start,end) 
  |a == 1 = if fst start < xi then 
                              overwrite xs ((xi, snd start), end) 
                              else 
                              overwrite xs (start, end) 
  |a == 2 = if fst end > xi then 
                              overwrite xs (start, (xi, snd end)) 
                              else 
                              overwrite xs (start, end) 
  |a == 3 = if snd start < yi then 
                              overwrite xs ((fst start, yi), end) 
                              else 
                              overwrite xs (start, end) 
  |otherwise = if snd end > yi then 
                              overwrite xs (start, (fst end, yi))
                              else 
                              overwrite xs (start, end) 
  where a = last x
        xi = head x
        yi = x !! 1


area :: Pos -> Pos -> Int
area (sx,sy) (ex,ey) = 
  case a < 0 of
    True -> 0
    False -> a
  let a = (ex-sx) * (ey-sy)

