fun main(args:Array<String>){
    val (w,h,n)=readInts()
    var (a,b,c,d)=listOf(0,0,w,h)
    for(i in 0 until n){
        val(x,y,z)=readInts()
        when(z){
            1->a=Math.max(a,x)
            2->c=Math.min(c,x)
            3->b=Math.max(b,y)
            4->d=Math.min(d,y)
        }
    }
    if(a>c||b>d){
        println(0)
    }else{
        println((c-a)*(d-b))
    }
}

fun readString() = readLine()!!
fun readStrings() = readString().split(" ")
fun readInt() = readString().toInt()
fun readInts() = readStrings().map { it.toInt() }
fun readLongs() = readStrings().map { it.toLong() }