local w,h,n=io.read("*n","*n","*n")
local rectangle={}
for i=1,h do
    rectangle[i]={}
    for j=1,w do
        rectangle[i][j]=1
    end
end
for i=1,n do
    local x,y,a=io.read("*n","*n","*n")
    if a==1 then
        for j=1,h do
            for k=1,x do
                rectangle[j][k]=0
            end
        end
    end
    if a==2 then
        for j=1,h do
            for k=x+1,w do
                rectangle[j][k]=0
            end
        end
    end
    if a==3 then
        for j=1,y do
            for k=1,w do
                rectangle[j][k]=0
            end
        end
    end
    if a==4 then
        for j=y+1,h do
            for k=1,w do
                rectangle[j][k]=0
            end
        end
    end
end

local total=0
for i=1,h do
    for j=1,w do
        total=total+rectangle[i][j]
    end
end
print(total)