import java.math.*

fun main(args: Array<String>) {
    val (W, H, N) = readInputLine().split(" ").map { it.toInt() }
    
    var l = 0
    var r = W
    var b = 0
    var t = H
    
    for (i in 1..N) {
        val (x, y, a) = readInputLine().split(" ").map { it.toInt() }
        when (a) {
            1 -> l = Math.max(l, x)
            2 -> r = Math.min(r, x)
            3 -> b = Math.max(b, y)
            4 -> t = Math.min(t, y)
        }
    }

    if ((t - b) > 0 && (r - l) > 0) {
        println((t - b) * (r - l))
    } else {
        println(0)
    }
}

fun readInputLine(): String {
    return readLine()!!
}
