import numpy as np

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

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

for i in range(n):

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

    if a==1:

        box[:, :x] = 0

    elif a==2:

        box[:, x:] = 0

    elif a==3:

        box[:y, :] = 0

    elif a==4:

        box[y:, :] = 0

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

y0 = 0

y1 = h

x0 = 0

x1 = w

for i in range(n):

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

    if a==1:

        x0 = max(x0, x)

    elif a==2:

        x1 = min(x1, x)

    elif a==3:

        y0 = max(y0, y)

    elif a==4:

        y1 = min(y1, y)

if (x1-x0>0) and (y1-y0>0):

    print(((x1-x0)*(y1-y0)))

else:

    print((0))
import numpy as np

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

w, h, n = list(map(int, input().split()))
y0 = 0
y1 = h
x0 = 0
x1 = w
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x0 = max(x0, x)
    elif a == 2:
        x1 = min(x1, x)
    elif a == 3:
        y0 = max(y0, y)
    elif a == 4:
        y1 = min(y1, y)
if (x1 - x0 > 0) and (y1 - y0 > 0):
    print(((x1 - x0) * (y1 - y0)))
else:
    print((0))

-import numpy as np - -box = np.ones((h, w)) +y0 = 0 +y1 = h +x0 = 0 +x1 = w -        box[:, :x] = 0 +        x0 = max(x0, x) -        box[:, x:] = 0 +        x1 = min(x1, x) -        box[:y, :] = 0 +        y0 = max(y0, y) -        box[y:, :] = 0 -print((sum(sum(box)))) +        y1 = min(y1, y) +if (x1 - x0 > 0) and (y1 - y0 > 0): +    print(((x1 - x0) * (y1 - y0))) +else: +    print((0))