# https://atcoder.jp/contests/abc047/tasks/abc047_b



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

area = [[0] * w for _ in range(h)]

for _ in range(n):

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

    if a == 1:

        for i in range(h):

            for j in range(w):

                if j < x:

                    area[i][j] = 1



    if a == 2:

        for i in range(h):

            for j in range(w):

                if j >= x:

                    area[i][j] = 1



    if a == 3:

        for i in range(h):

            for j in range(w):

                if i < y:

                    area[i][j] = 1



    if a == 4:

        for i in range(h):

            for j in range(w):

                if i >= y:

                    area[i][j] = 1



ans = 0

for i in range(h):

    for j in range(w):

        if area[i][j] == 0:

            ans += 1



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

left_x = 0

right_x = w

up_y = h

down_y = 0

for _ in range(n):

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

    if a == 1:

        left_x = max(left_x, x)

    elif a == 2:

        right_x = min(right_x, x)

    elif a == 3:

        down_y = max(down_y, y)

    else:

        up_y = min(up_y, y)



if right_x - left_x > 0 and up_y - down_y > 0:

    ans = (right_x - left_x) * (up_y - down_y)

else:

    ans = 0

print(ans)
# https://atcoder.jp/contests/abc047/tasks/abc047_b
w, h, n = list(map(int, input().split()))
area = [[0] * w for _ in range(h)]
for _ in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for i in range(h):
            for j in range(w):
                if j < x:
                    area[i][j] = 1
    if a == 2:
        for i in range(h):
            for j in range(w):
                if j >= x:
                    area[i][j] = 1
    if a == 3:
        for i in range(h):
            for j in range(w):
                if i < y:
                    area[i][j] = 1
    if a == 4:
        for i in range(h):
            for j in range(w):
                if i >= y:
                    area[i][j] = 1
ans = 0
for i in range(h):
    for j in range(w):
        if area[i][j] == 0:
            ans += 1
print(ans)

w, h, n = list(map(int, input().split()))
left_x = 0
right_x = w
up_y = h
down_y = 0
for _ in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        left_x = max(left_x, x)
    elif a == 2:
        right_x = min(right_x, x)
    elif a == 3:
        down_y = max(down_y, y)
    else:
        up_y = min(up_y, y)
if right_x - left_x > 0 and up_y - down_y > 0:
    ans = (right_x - left_x) * (up_y - down_y)
else:
    ans = 0
print(ans)

-# https://atcoder.jp/contests/abc047/tasks/abc047_b -area = [[0] * w for _ in range(h)] +left_x = 0 +right_x = w +up_y = h +down_y = 0 -        for i in range(h): -            for j in range(w): -                if j < x: -                    area[i][j] = 1 -    if a == 2: -        for i in range(h): -            for j in range(w): -                if j >= x: -                    area[i][j] = 1 -    if a == 3: -        for i in range(h): -            for j in range(w): -                if i < y: -                    area[i][j] = 1 -    if a == 4: -        for i in range(h): -            for j in range(w): -                if i >= y: -                    area[i][j] = 1 -ans = 0 -for i in range(h): -    for j in range(w): -        if area[i][j] == 0: -            ans += 1 +        left_x = max(left_x, x) +    elif a == 2: +        right_x = min(right_x, x) +    elif a == 3: +        down_y = max(down_y, y) +    else: +        up_y = min(up_y, y) +if right_x - left_x > 0 and up_y - down_y > 0: +    ans = (right_x - left_x) * (up_y - down_y) +else: +    ans = 0