integer w,h,n
integer x,y,a
integer l,r,d,u
read*,w,h,n
l=0;r=w;d=0;u=h
do i=1,n
read*,x,y,a
if (a==1)l=max(l,x)
if (a==2)r=min(r,x)
if (a==3)d=max(d,y)	
if (a==4)u=min(u,y)
end do
print"(I0)",merge(0,(r-l)*(u-d),l>r.or.d>u)
end