fun main(args: Array<String>) {
    val (w, h, n) = readLine()!!.split(" ").map { it.toInt() }
    var l = 0
    var r = w
    var d = 0
    var u = h
    for (i in 0 until n) {
        var(x, y, a) = readLine()!!.split(" ").map { it.toInt() }
        when(a) {
            1 -> l = Math.max(l, x)
            2 -> r = Math.min(r, x)
            3 -> d = Math.max(d, y)
            4 -> u = Math.min(u, y)
        }
    }
    println(Math.max(r-l, 0) * Math.max(u-d, 0))
}