import io.{StdIn => in}

object Main extends App {
  val Array(w, h, n) = in.readLine.split(" ").map(_.toInt)
  val table = Array.ofDim[Boolean](h, w)
  Iterator.continually(in.readLine.split(" ").map(_.toInt))
    .take(n)
    .foreach(a => {
      val xi = a(0)
      val yi = a(1)
      a(2) match {
        case 1 => table.foreach(t => (0 until xi).foreach(i => t(i) = true))
        case 2 => table.foreach(t => (xi until w).foreach(i => t(i) = true))
        case 3 => table.take(yi)foreach(t => (0 until w).foreach(i => t(i) = true))
        case 4 => table.drop(yi)foreach(t => (0 until w).foreach(i => t(i) = true))
      }
    })

  val ans = table./:(0)((acc, e) => acc + e.count(_ == false))
  println(ans)
}