data class Point(val x: Int, val y: Int, val a: Int)

fun main(args: Array<String>) {
    val (w, h, n) = readLine()?.split(" ")?.map { it.toInt() } ?: return
    val points: List<Point> = (0 until n).map {
        val (x, y, a) = readLine()?.split(" ")?.map { it.toInt() }!!
        Point(x, y, a)
    }

    var startX = 0
    var endX = w
    var startY = 0
    var endY = h

    for (point in points) {
        when (point.a) {
            1 -> {
                if (startX < point.x) {
                    startX = point.x
                }
            }
            2 -> {
                if (endX > point.x) {
                    endX = point.x
                }
            }
            3 -> {
                if (startY < point.y) {
                    startY = point.y
                }
            }
            4 -> {
                if (endY > point.y) {
                    endY = point.y
                }
            }
        }
    }
    if (startX >= endX || startY >= endY) {
        println(0)
    } else {
        println((endX - startX) * (endY - startY))
    }
}