fn = lambda: list(map(int, input().split()))

W, H, N = fn()

A = [[1 for _ in range(W)] for _ in range(H)]

for _ in range(N):

    x, y, a = fn()

    if a == 1:

        for i in range(H):

            for j in range(x):

                A[i][j] = 0

    elif a == 2:

        for i in range(H):

            for j in range(x, W):

                A[i][j] = 0

    elif a == 3:

        for i in range(W):

            for j in range(y):

                A[j][i] = 0

    elif a == 4:

        for i in range(W):

            for j in range(y, H):

                A[j][i] = 0

    else:

        print('Something wrong')



print((sum([sum(Ai) for Ai in A])))

fn = lambda: list(map(int, input().split()))

W, H, N = fn()

min_x, max_x = 0, W

min_y, max_y = 0, H

for i in range(N):

    xi, yi, ai = fn()

    if ai == 1:

        min_x = max(xi, min_x)

    elif ai == 2:

        max_x = min(xi, max_x)

    elif ai == 3:

        min_y = max(yi, min_y)

    elif ai == 4:

        max_y = min(yi, max_y)

    else:

        print('Something wrong')



print((max(max_x - min_x, 0) * max(max_y - min_y, 0)))
fn = lambda: list(map(int, input().split()))
W, H, N = fn()
A = [[1 for _ in range(W)] for _ in range(H)]
for _ in range(N):
    x, y, a = fn()
    if a == 1:
        for i in range(H):
            for j in range(x):
                A[i][j] = 0
    elif a == 2:
        for i in range(H):
            for j in range(x, W):
                A[i][j] = 0
    elif a == 3:
        for i in range(W):
            for j in range(y):
                A[j][i] = 0
    elif a == 4:
        for i in range(W):
            for j in range(y, H):
                A[j][i] = 0
    else:
        print("Something wrong")
print((sum([sum(Ai) for Ai in A])))

fn = lambda: list(map(int, input().split()))
W, H, N = fn()
min_x, max_x = 0, W
min_y, max_y = 0, H
for i in range(N):
    xi, yi, ai = fn()
    if ai == 1:
        min_x = max(xi, min_x)
    elif ai == 2:
        max_x = min(xi, max_x)
    elif ai == 3:
        min_y = max(yi, min_y)
    elif ai == 4:
        max_y = min(yi, max_y)
    else:
        print("Something wrong")
print((max(max_x - min_x, 0) * max(max_y - min_y, 0)))

-A = [[1 for _ in range(W)] for _ in range(H)] -for _ in range(N): -    x, y, a = fn() -    if a == 1: -        for i in range(H): -            for j in range(x): -                A[i][j] = 0 -    elif a == 2: -        for i in range(H): -            for j in range(x, W): -                A[i][j] = 0 -    elif a == 3: -        for i in range(W): -            for j in range(y): -                A[j][i] = 0 -    elif a == 4: -        for i in range(W): -            for j in range(y, H): -                A[j][i] = 0 +min_x, max_x = 0, W +min_y, max_y = 0, H +for i in range(N): +    xi, yi, ai = fn() +    if ai == 1: +        min_x = max(xi, min_x) +    elif ai == 2: +        max_x = min(xi, max_x) +    elif ai == 3: +        min_y = max(yi, min_y) +    elif ai == 4: +        max_y = min(yi, max_y) -print((sum([sum(Ai) for Ai in A]))) +print((max(max_x - min_x, 0) * max(max_y - min_y, 0)))