w,h,n=(int (i) for i in input().split())

w1=0
w2=w
h3=0
h4=h

for i in range(n):
    x,y,a=(int (i) for i in input().split())
    if a==1 and x>w1:
        w1=x
    elif a==2 and x<w2:
        w2=x
    elif a==3 and y>h3:
        h3=y
    elif a==4 and y<h4:
        h4=y

s=(w-w1-(w-w2))*(h-h3-(h-h4))

if s<=0:
    print(0)
else:
    print(s)
