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

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

area = [[0 for i in range(H)] for j in range(W)]

for i in range(N):

    if zahyo[i][2] == 1:

        for j in range(zahyo[i][0]):

            for k in range(H):

                area[j][k] = 1

                

    elif zahyo[i][2] == 2:

        for j in range(zahyo[i][0], W):

            for k in range(H):

                area[j][k] = 1

                

    elif zahyo[i][2] == 3:

        for j in range(W):

            for k in range(zahyo[i][1]):

                area[j][k] = 1

                

    elif zahyo[i][2] == 4:

        for j in range(W):

            for k in range(zahyo[i][1], H):

                area[j][k] = 1



cnt = 0

for l in area:

    for m in range(H):

        if l[m] == 0:

            cnt += 1

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

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

x_min = y_min = 0

x_max = W

y_max = H

for i in range(N):

    if zahyo[i][2] == 1:

        if x_min < zahyo[i][0]:

            x_min = zahyo[i][0]

    

    elif zahyo[i][2] == 2:

        if zahyo[i][0] < x_max:

            x_max = zahyo[i][0]

            

    elif zahyo[i][2] == 3:

        if y_min < zahyo[i][1]:

            y_min = zahyo[i][1]

            

    elif zahyo[i][2] == 4:

        if zahyo[i][1] < y_max:

            y_max = zahyo[i][1]

    

if (x_max - x_min) > 0 and  (y_max - y_min) > 0:

    print(((x_max - x_min) * (y_max - y_min)))

else:

    print((0))
W, H, N = list(map(int, input().split()))
zahyo = [list(map(int, input().split())) for i in range(N)]
area = [[0 for i in range(H)] for j in range(W)]
for i in range(N):
    if zahyo[i][2] == 1:
        for j in range(zahyo[i][0]):
            for k in range(H):
                area[j][k] = 1
    elif zahyo[i][2] == 2:
        for j in range(zahyo[i][0], W):
            for k in range(H):
                area[j][k] = 1
    elif zahyo[i][2] == 3:
        for j in range(W):
            for k in range(zahyo[i][1]):
                area[j][k] = 1
    elif zahyo[i][2] == 4:
        for j in range(W):
            for k in range(zahyo[i][1], H):
                area[j][k] = 1
cnt = 0
for l in area:
    for m in range(H):
        if l[m] == 0:
            cnt += 1
print(cnt)

W, H, N = list(map(int, input().split()))
zahyo = [list(map(int, input().split())) for i in range(N)]
x_min = y_min = 0
x_max = W
y_max = H
for i in range(N):
    if zahyo[i][2] == 1:
        if x_min < zahyo[i][0]:
            x_min = zahyo[i][0]
    elif zahyo[i][2] == 2:
        if zahyo[i][0] < x_max:
            x_max = zahyo[i][0]
    elif zahyo[i][2] == 3:
        if y_min < zahyo[i][1]:
            y_min = zahyo[i][1]
    elif zahyo[i][2] == 4:
        if zahyo[i][1] < y_max:
            y_max = zahyo[i][1]
if (x_max - x_min) > 0 and (y_max - y_min) > 0:
    print(((x_max - x_min) * (y_max - y_min)))
else:
    print((0))

-area = [[0 for i in range(H)] for j in range(W)] +x_min = y_min = 0 +x_max = W +y_max = H -        for j in range(zahyo[i][0]): -            for k in range(H): -                area[j][k] = 1 +        if x_min < zahyo[i][0]: +            x_min = zahyo[i][0] -        for j in range(zahyo[i][0], W): -            for k in range(H): -                area[j][k] = 1 +        if zahyo[i][0] < x_max: +            x_max = zahyo[i][0] -        for j in range(W): -            for k in range(zahyo[i][1]): -                area[j][k] = 1 +        if y_min < zahyo[i][1]: +            y_min = zahyo[i][1] -        for j in range(W): -            for k in range(zahyo[i][1], H): -                area[j][k] = 1 -cnt = 0 -for l in area: -    for m in range(H): -        if l[m] == 0: -            cnt += 1 -print(cnt) +        if zahyo[i][1] < y_max: +            y_max = zahyo[i][1] +if (x_max - x_min) > 0 and (y_max - y_min) > 0: +    print(((x_max - x_min) * (y_max - y_min))) +else: +    print((0))