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

graph = [[1] * 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(x):

                graph[i][j] = 0

    if a == 2:

        for i in range(H):

            for j in range(x, W):

                graph[i][j] = 0

    if a == 3:

        for i in range(y):

            for j in range(W):

                graph[i][j] = 0

    if a == 4:

        for i in range(y, H):

            for j in range(W):

                graph[i][j] = 0

ans = sum([sum(line) for line in graph])

print(ans)

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

lx, rx, uy, dy = 0, W, H, 0

for i in range(N):

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

    if a == 1:

        lx = max(lx, x)

    if a == 2:

        rx = min(rx, x)

    if a == 3:

        dy = max(dy, y)

    if a == 4:

        uy = min(uy, y)

# print(lx, rx, uy, dy)

print((max(0, uy - dy) * max(0, rx - lx)))

W, H, N = list(map(int, input().split()))
graph = [[1] * 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(x):
                graph[i][j] = 0
    if a == 2:
        for i in range(H):
            for j in range(x, W):
                graph[i][j] = 0
    if a == 3:
        for i in range(y):
            for j in range(W):
                graph[i][j] = 0
    if a == 4:
        for i in range(y, H):
            for j in range(W):
                graph[i][j] = 0
ans = sum([sum(line) for line in graph])
print(ans)

W, H, N = list(map(int, input().split()))
lx, rx, uy, dy = 0, W, H, 0
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        lx = max(lx, x)
    if a == 2:
        rx = min(rx, x)
    if a == 3:
        dy = max(dy, y)
    if a == 4:
        uy = min(uy, y)
# print(lx, rx, uy, dy)
print((max(0, uy - dy) * max(0, rx - lx)))

-graph = [[1] * W for _ in range(H)] -for _ in range(N): +lx, rx, uy, dy = 0, W, H, 0 +for i in range(N): -        for i in range(H): -            for j in range(x): -                graph[i][j] = 0 +        lx = max(lx, x) -        for i in range(H): -            for j in range(x, W): -                graph[i][j] = 0 +        rx = min(rx, x) -        for i in range(y): -            for j in range(W): -                graph[i][j] = 0 +        dy = max(dy, y) -        for i in range(y, H): -            for j in range(W): -                graph[i][j] = 0 -ans = sum([sum(line) for line in graph]) -print(ans) +        uy = min(uy, y) +# print(lx, rx, uy, dy) +print((max(0, uy - dy) * max(0, rx - lx)))