W,H,N = list(map(int,input().split()))

X1 = W

X2 = 0

Y1 = H

Y2 = 0

for _ in range(N):

    x,y,a = list(map(int,input().split()))

    if a==1:

        X2 = max(X2,x)

    elif a==2:

        X1 = min(X1,x)

    elif a==3:

        Y2 = max(Y2,y)

    elif a==4:

        Y1 = min(Y1,y)

if X2>=X1 and Y2>=Y1:

    ans = 0

elif X2>=X1 and Y2<Y1:

    ans = 0

elif X2<X1 and Y2>=Y1:

    ans = 0

elif X2<X1 and Y2<Y1:

    ans = (X1-X2)*(Y1-Y2)

print(ans)
W,H,N = list(map(int,input().split()))

xl = 0

xh = W

yl = 0

yh = H

for _ in range(N):

    x,y,a = list(map(int,input().split()))

    if a==1:

        xl = max(xl,x)

    elif a==2:

        xh = min(xh,x)

    elif a==3:

        yl = max(yl,y)

    elif a==4:

        yh = min(yh,y)

dx = max(0,xh-xl)

dy = max(0,yh-yl)

print((dx*dy))
W, H, N = list(map(int, input().split()))
X1 = W
X2 = 0
Y1 = H
Y2 = 0
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        X2 = max(X2, x)
    elif a == 2:
        X1 = min(X1, x)
    elif a == 3:
        Y2 = max(Y2, y)
    elif a == 4:
        Y1 = min(Y1, y)
if X2 >= X1 and Y2 >= Y1:
    ans = 0
elif X2 >= X1 and Y2 < Y1:
    ans = 0
elif X2 < X1 and Y2 >= Y1:
    ans = 0
elif X2 < X1 and Y2 < Y1:
    ans = (X1 - X2) * (Y1 - Y2)
print(ans)

W, H, N = list(map(int, input().split()))
xl = 0
xh = W
yl = 0
yh = H
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        xl = max(xl, x)
    elif a == 2:
        xh = min(xh, x)
    elif a == 3:
        yl = max(yl, y)
    elif a == 4:
        yh = min(yh, y)
dx = max(0, xh - xl)
dy = max(0, yh - yl)
print((dx * dy))

-X1 = W -X2 = 0 -Y1 = H -Y2 = 0 +xl = 0 +xh = W +yl = 0 +yh = H -        X2 = max(X2, x) +        xl = max(xl, x) -        X1 = min(X1, x) +        xh = min(xh, x) -        Y2 = max(Y2, y) +        yl = max(yl, y) -        Y1 = min(Y1, y) -if X2 >= X1 and Y2 >= Y1: -    ans = 0 -elif X2 >= X1 and Y2 < Y1: -    ans = 0 -elif X2 < X1 and Y2 >= Y1: -    ans = 0 -elif X2 < X1 and Y2 < Y1: -    ans = (X1 - X2) * (Y1 - Y2) -print(ans) +        yh = min(yh, y) +dx = max(0, xh - xl) +dy = max(0, yh - yl) +print((dx * dy))