import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val w = sc.nextInt()
  val h = sc.nextInt()
  val n = sc.nextInt()
  val xya = (1..n).map { Triple(sc.nextInt(), sc.nextInt(), sc.nextInt()) }


  val array = Array(h) { Array(w) { false } }
  for (i in xya) {
    val x = i.first
    val y = i.second
    val a = i.third
    if (a == 1) {
      for (yi in 0 until h) {
        val ai = array[yi]
        for (xi in 0 until x) {
          ai[xi] = true
        }
      }
    } else if (a == 2) {
      for (yi in 0 until h) {
        val ai = array[yi]
        for (xi in x until w) {
          ai[xi] = true
        }
      }
    } else if (a == 3) {
      for (yi in 0 until y) {
        val ai = array[yi]
        for (xi in 0 until w) {
          ai[xi] = true
        }
      }
    } else if (a == 4) {
      for (yi in y until h) {
        val ai = array[yi]
        for (xi in 0 until w) {
          ai[xi] = true
        }
      }
    }
  }


  var count = 0
  for (ai in array) {
    for (aii in ai) {
      if (aii) count++
    }
  }

  val total = h * w
  println(total - count)

}