local read = io.read

local W, H, N = read("*n", "*n", "*n")
local rectangle = {}
for x = 1, W do
	rectangle[x] = {}
	for y = 1, H do
		rectangle[x][y] = true
	end
end

local function paint(x_i, y_i, a_i)
	if a_i == 1 then
		for x = 1, x_i do
			for y = 1, H do
				rectangle[x][y] = false
			end
		end
	elseif a_i == 2 then
		for x = x_i + 1, W do
			for y = 1, H do
				rectangle[x][y] = false
			end
		end
	elseif a_i == 3 then
		for x = 1, W do
			for y = 1, y_i do
				rectangle[x][y] = false
			end
		end
	else
		for x = 1, W do
			for y = y_i + 1, H do
				rectangle[x][y] = false
			end
		end
	end
end

for i = 1, N do
	paint(read("*n", "*n", "*n"))
end

local out = 0
for x = 1, W do
	for y = 1, H do
		if rectangle[x][y] then
			out = out + 1
		end
	end
end

print(out)
