fun main() {
    val input = readLine()!!.split(" ").map { it.toInt() }
    val w = input[0]
    val h = input[1]
    val n = input[2]

    var xMin = 0
    var xMax = w
    var yMin = 0
    var yMax = h

    for (i in 0 until n) {
        val input2 = readLine()!!.split(" ").map { it.toInt() }
        val tmpX = input2[0]
        val tmpY = input2[1]

        when (input2[2]) {
            (1) -> xMin = if ( xMin < tmpX) tmpX else xMin
            (2) -> xMax = if ( tmpX < xMax) tmpX else xMax
            (3) -> yMin = if ( yMin < tmpY) tmpY else yMin
            (4) -> yMax = if ( tmpY < yMax) tmpY else yMax
        }
    }

    if (xMax <= xMin || yMax <= yMin) {
        print(0)
        return
    }

    print((xMax - xMin) * (yMax - yMin))
}