fun main(args: Array<String>) {
    val (w, h, n) = readLine()!!.split(" ").map(String::toInt)
    var top = h
    var bottom = 0
    var left = 0
    var right = w
    for (i in 1..n) {
        val (x, y, a) = readLine()!!.split(" ").map(String::toInt)
        if (a == 1 && left < x) {
            left = x
        } else if (a == 2 && x < right) {
            right = x
        } else if (a == 3 && bottom < y) {
            bottom = y
        } else if (a == 4 && y < top) {
            top = y
        }
    }
    val height = top - bottom
    val width = right - left
    val area = if (height <= 0 || width <= 0) 0 else height * width
    println(area)
}
