fun main(args: Array<String>) {
	val (w, h, n) = readLine()!!.split(' ').map { it.toInt() }
	val arr = Array(h) { Array(w) { 1 } }
	var ans = 0

	for (i in n - 1 downTo 0) {
		val (xi, yi, a) = readLine()!!.split(' ').map { it.toInt() }

		for (y in 0 until h) {
			for (x in 0 until w) {
				if ((a == 1 && x < xi) || (a == 2 && x >= xi) ||
						(a == 3 && y < yi) || (a == 4 && y >= yi)) {
					arr[y][x] = 0
				}
				if (i == 0) {
					ans += arr[y][x]
				}
			}
		}
	}
	println(ans)
}
