fun main(args: Array<String>) {
    abc047b()
}

// 黒く塗らない方向
private enum class Direction { RIGHT, LEFT, ABOVE, BELOW }

private data class Xya(val x: Int, val y: Int, val direction: Direction)

fun abc047b() {
    val (w, h, n) = readLine()!!.split(" ").map { it.toInt() }
    val xyaList = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
        .map {
            Xya(
                it[0], it[1], when (it[2]) {
                    1 -> Direction.RIGHT
                    2 -> Direction.LEFT
                    3 -> Direction.ABOVE
                    else -> Direction.BELOW
                }
            )
        }

    val left = xyaList.filter { it.direction == Direction.RIGHT }
        .maxBy { it.x }?.x ?: 0
    val right = xyaList.filter { it.direction == Direction.LEFT }
        .minBy { it.x }?.x ?: w
    val below = xyaList.filter { it.direction == Direction.ABOVE }
        .maxBy { it.y }?.y ?: 0
    val above = xyaList.filter { it.direction == Direction.BELOW }
        .minBy { it.y }?.y ?: h

    val answer = Math.max(0, (right - left)) * Math.max(0, (above - below))

    println(answer)
}
