fun main(args: Array<String>) {
    val (W, H, N) = readLine()!!.split(" ").map(String::toInt)
    val A = Array(N) { readLine()!!.split(" ").map(String::toInt) }

    var x1 = 0
    var x2 = W
    var y1 = 0
    var y2 = H

    A.forEach { n ->
        val (x, y, a) = n
        when (a) {
            1 -> x1 = Math.max(x1, x)
            2 -> x2 = Math.min(x2, x)
            3 -> y1 = Math.max(y1, y)
            else -> y2 = Math.min(y2, y)
        }
    }
    if (x1 > x2) {
        println(0)
        return
    }
    if (y1 > y2) {
        println(0)
        return
    }

    println((W - x1 - (W - x2)) * (H - y1 - (H - y2)))
}

