w, h, n = io.read("*n", "*n", "*n")

l, r, u, d = 0, w, h, 0 

for i = 1, n do
	x, y, a = io.read("*n", "*n", "*n")
	if a == 1 then l = math.max(l, x)
	elseif a == 2 then r = math.min(r, x)
	elseif a == 3 then d = math.max(d, y)
	else u = math.min(u, y) end
end

print(math.max(0, r-l) * math.max(0, u-d))
