fun main(args: Array<String>) {
  val (W, H, N) = readLine()!!.split(" ").map(String::toInt)
  var (left, right, bottom, top) = arrayOf(0, W, 0, H)
  for(i in 1..N){
    val (x, y, a) = readLine()!!.split(" ").map(String::toInt)
    when(a){
      1 -> left = max(x, left)
      2 -> right = min(x, right)
      3 -> bottom = max(y, bottom)
      4 -> top = min(y, top)
      else -> 0
    }
  }
  println(max((right-left),0)*max((top-bottom),0))
}
 
fun <T:Comparable<T>> max(a: T, b: T): T{
    return if(a<b) b else a
}
fun <T:Comparable<T>> min(a: T, b: T): T{
    return if(a>b) b else a
}