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

xya=[list(map(int,input().split())) for _ in range(N)]



x_l=0

x_h=W

y_l=0

y_h=H



for i in xya:

    if i[2]==1 and x_l<i[0]:

        x_l=i[0]

    elif i[2]==2 and x_h>i[0]:

        x_h=i[0]

    elif i[2]==3 and y_l<i[1]:

        y_l=i[1]

    elif i[2]==4 and y_h>i[1]:

        y_h=i[1]



print((max(0,x_h-x_l)*max(0,y_h-y_l)))
W,H,N=list(map(int,input().split()))

x_l=0

x_r=W

y_h=H

y_l=0



for i in range(N):

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

    if a==1:

        x_l=max(x_l,x)

    elif a==2:

        x_r=min(x_r,x)

    elif a==3:

        y_l=max(y_l,y)

    else:

        y_h=min(y_h,y)



#print(x_l,x_r,y_h,y_l)



print((max(x_r-x_l,0)*max(y_h-y_l,0)))
W, H, N = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(N)]
x_l = 0
x_h = W
y_l = 0
y_h = H
for i in xya:
    if i[2] == 1 and x_l < i[0]:
        x_l = i[0]
    elif i[2] == 2 and x_h > i[0]:
        x_h = i[0]
    elif i[2] == 3 and y_l < i[1]:
        y_l = i[1]
    elif i[2] == 4 and y_h > i[1]:
        y_h = i[1]
print((max(0, x_h - x_l) * max(0, y_h - y_l)))

W, H, N = list(map(int, input().split()))
x_l = 0
x_r = W
y_h = H
y_l = 0
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x_l = max(x_l, x)
    elif a == 2:
        x_r = min(x_r, x)
    elif a == 3:
        y_l = max(y_l, y)
    else:
        y_h = min(y_h, y)
# print(x_l,x_r,y_h,y_l)
print((max(x_r - x_l, 0) * max(y_h - y_l, 0)))

-xya = [list(map(int, input().split())) for _ in range(N)] -x_h = W +x_r = W +y_h = H -y_h = H -for i in xya: -    if i[2] == 1 and x_l < i[0]: -        x_l = i[0] -    elif i[2] == 2 and x_h > i[0]: -        x_h = i[0] -    elif i[2] == 3 and y_l < i[1]: -        y_l = i[1] -    elif i[2] == 4 and y_h > i[1]: -        y_h = i[1] -print((max(0, x_h - x_l) * max(0, y_h - y_l))) +for i in range(N): +    x, y, a = list(map(int, input().split())) +    if a == 1: +        x_l = max(x_l, x) +    elif a == 2: +        x_r = min(x_r, x) +    elif a == 3: +        y_l = max(y_l, y) +    else: +        y_h = min(y_h, y) +# print(x_l,x_r,y_h,y_l) +print((max(x_r - x_l, 0) * max(y_h - y_l, 0)))