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

rect = []

for i in range(h):

    rect.append([0 for _ in range(w)])

for i in range(n):

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

    if a == 1:

        for i in range(h):

            for j in range(x):

                rect[i][j] = 1

    elif a == 2:

        for i in range(h):

            for j in range(w-1, x-1, -1):

                rect[i][j] = 1

    elif a == 3:

        for i in range(y):

            for j in range(w):

                rect[i][j] = 1

    else:

        for i in range(y, h):

            for j in range(w):

                rect[i][j] = 1

count = 0

for i in range(h):

    for j in range(w):

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

            count += 1

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

min_x = 0

min_y = 0

w = W

h = H

for i in range(N):

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

    if a == 1: min_x = max(min_x, x)

    elif a == 2: w = min(w, x)

    elif a == 3: min_y = max(min_y, y)

    elif a == 4: h = min(h, y)

print(((w-min_x)*(h-min_y) if (w-min_x)>0 and (h-min_y)>0 else 0))
w, h, n = list(map(int, input().split()))
rect = []
for i in range(h):
    rect.append([0 for _ in range(w)])
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for i in range(h):
            for j in range(x):
                rect[i][j] = 1
    elif a == 2:
        for i in range(h):
            for j in range(w - 1, x - 1, -1):
                rect[i][j] = 1
    elif a == 3:
        for i in range(y):
            for j in range(w):
                rect[i][j] = 1
    else:
        for i in range(y, h):
            for j in range(w):
                rect[i][j] = 1
count = 0
for i in range(h):
    for j in range(w):
        if rect[i][j] == 0:
            count += 1
print(count)

W, H, N = list(map(int, input().split()))
min_x = 0
min_y = 0
w = W
h = H
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        min_x = max(min_x, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        min_y = max(min_y, y)
    elif a == 4:
        h = min(h, y)
print(((w - min_x) * (h - min_y) if (w - min_x) > 0 and (h - min_y) > 0 else 0))

-w, h, n = list(map(int, input().split())) -rect = [] -for i in range(h): -    rect.append([0 for _ in range(w)]) -for i in range(n): +W, H, N = list(map(int, input().split())) +min_x = 0 +min_y = 0 +w = W +h = H +for i in range(N): -        for i in range(h): -            for j in range(x): -                rect[i][j] = 1 +        min_x = max(min_x, x) -        for i in range(h): -            for j in range(w - 1, x - 1, -1): -                rect[i][j] = 1 +        w = min(w, x) -        for i in range(y): -            for j in range(w): -                rect[i][j] = 1 -    else: -        for i in range(y, h): -            for j in range(w): -                rect[i][j] = 1 -count = 0 -for i in range(h): -    for j in range(w): -        if rect[i][j] == 0: -            count += 1 -print(count) +        min_y = max(min_y, y) +    elif a == 4: +        h = min(h, y) +print(((w - min_x) * (h - min_y) if (w - min_x) > 0 and (h - min_y) > 0 else 0))