import numpy as np





w, h, n = list(map(int, input().split()))

rectangle = np.ones((w, h))



for j in range(n):

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

    if a == 1:

        rectangle[:x, :] = 0

    elif a == 2:

        rectangle[x:, :] = 0



    elif a == 3:

        rectangle[:, :y] = 0



    elif a == 4:

        rectangle[:, y:] = 0



print((int(np.sum(rectangle))))

w, h, n = list(map(int, input().split()))



min_x = 0

max_x = w

min_y = 0

max_y = h



for i in range(n):

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

    if a == 1 and min_x < x:

        min_x = x

    if a == 2 and x < max_x:

        max_x = x

    if a == 3 and min_y < y:

        min_y = y

    if a == 4 and y < max_y:

        max_y = y



ans = (max_x-min_x)*(max_y-min_y)

if max_x-min_x < 0 or max_y-min_y < 0:

    ans = 0



print(ans)
import numpy as np

w, h, n = list(map(int, input().split()))
rectangle = np.ones((w, h))
for j in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        rectangle[:x, :] = 0
    elif a == 2:
        rectangle[x:, :] = 0
    elif a == 3:
        rectangle[:, :y] = 0
    elif a == 4:
        rectangle[:, y:] = 0
print((int(np.sum(rectangle))))

w, h, n = list(map(int, input().split()))
min_x = 0
max_x = w
min_y = 0
max_y = h
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1 and min_x < x:
        min_x = x
    if a == 2 and x < max_x:
        max_x = x
    if a == 3 and min_y < y:
        min_y = y
    if a == 4 and y < max_y:
        max_y = y
ans = (max_x - min_x) * (max_y - min_y)
if max_x - min_x < 0 or max_y - min_y < 0:
    ans = 0
print(ans)

-import numpy as np - -rectangle = np.ones((w, h)) -for j in range(n): +min_x = 0 +max_x = w +min_y = 0 +max_y = h +for i in range(n): -    if a == 1: -        rectangle[:x, :] = 0 -    elif a == 2: -        rectangle[x:, :] = 0 -    elif a == 3: -        rectangle[:, :y] = 0 -    elif a == 4: -        rectangle[:, y:] = 0 -print((int(np.sum(rectangle)))) +    if a == 1 and min_x < x: +        min_x = x +    if a == 2 and x < max_x: +        max_x = x +    if a == 3 and min_y < y: +        min_y = y +    if a == 4 and y < max_y: +        max_y = y +ans = (max_x - min_x) * (max_y - min_y) +if max_x - min_x < 0 or max_y - min_y < 0: +    ans = 0 +print(ans)