fun main(args: Array<String>) {
    val (w,h,n)= readLine()!!.split(" ").map { it.toInt() }
    val xya = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }

    var l=0
    var r=w
    var u=h
    var d=0
    xya.forEach {
        when(it[2]){
            1 -> l=Math.max(l,it[0])
            2 -> r=Math.min(r,it[0])
            3 -> d=Math.max(d,it[1])
            4 -> u=Math.min(u,it[1])
        }
    }
    if(r-l<0||u-d<0){
        println(0)
    }else{
        println((r-l)*(u-d))
    }
}