object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val w, h, n = sc.nextInt()
  val xya = List.fill(n)((sc.nextInt(), sc.nextInt(), sc.nextInt()))
  var l = 0
  var r = w
  var b = 0
  var t = h
  for ((x, y, a) <- xya) {
    a match {
      case 1 => l = l.max(x)
      case 2 => r = r.min(x)
      case 3 => b = b.max(y)
      case 4 => t = t.min(y)
    }
  }
  println((r-l).max(0) * (t-b).max(0))
}
