let solve w h xya_lst =
    let rec solve' xya_lst sx sy ex ey =
        match xya_lst with
        | [] -> (sx, sy, ex, ey)
        | x::xs ->
            let x, y, a = x
            let nsx, nsy, nex, ney =
                match a with
                | 1 -> max sx x, sy, ex, ey
                | 2 -> sx, sy, min ex x, ey
                | 3 -> sx, max sy y, ex, ey
                | _ -> sx, sy, ex, min ey y
            solve' xs nsx nsy nex ney
    let sx, sy, ex, ey = solve' xya_lst 0 0 w h
    let bw = if sx < ex then ex - sx else 0
    let bh = if sy < ey then ey - sy else 0
    bw * bh

let () =
    let w, h, n = stdin.ReadLine () |>
                  (fun str -> str.Split()) |>
                  Array.map int |>
                  fun arr -> (arr.[0], arr.[1], arr.[2])
    let xya_lst = seq {
        for i in 1..n do
            let x, y, a = stdin.ReadLine () |>
                          (fun str -> str.Split()) |>
                          Array.map int |>
                          fun arr -> (arr.[0], arr.[1], arr.[2])
            yield (x, y, a) } |> List.ofSeq

    solve w h xya_lst |> printfn "%d"
