from operator import itemgetter



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

binary = [[0 for _ in range(h)] for i in range(w)]



for i in range(n):

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

    if a == 1:

        for j in range(x):

            for k in range(h):

                binary[j][k] += 1

    elif a == 2:

        for j in range(x,w):

            for k in range(h):

                binary[j][k] += 1

    elif a == 3:

        for j in range(w):

            for k in range(y):

                binary[j][k] += 1

    elif a == 4:

        for j in range(w):

            for k in range(y,h):

                binary[j][k] += 1



total = 0

for i in range(len(binary)):

    total += binary[i].count(0) 

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

W = [1] * w

H = [1] * h



for i in range(n):

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

    if a == 1:

        for j in range(x):

            W[j] = 0

    elif a == 2:

        for j in range(x, w):

            W[j] = 0

    elif a == 3:

        for j in range(y):

            H[j] = 0

    elif a == 4:

        for j in range(y, h):

            H[j] = 0

print((sum(W) * sum(H)))
from operator import itemgetter

w, h, n = list(map(int, input().split()))
binary = [[0 for _ in range(h)] for i in range(w)]
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for j in range(x):
            for k in range(h):
                binary[j][k] += 1
    elif a == 2:
        for j in range(x, w):
            for k in range(h):
                binary[j][k] += 1
    elif a == 3:
        for j in range(w):
            for k in range(y):
                binary[j][k] += 1
    elif a == 4:
        for j in range(w):
            for k in range(y, h):
                binary[j][k] += 1
total = 0
for i in range(len(binary)):
    total += binary[i].count(0)
print(total)

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

-from operator import itemgetter - -binary = [[0 for _ in range(h)] for i in range(w)] +W = [1] * w +H = [1] * h -            for k in range(h): -                binary[j][k] += 1 +            W[j] = 0 -            for k in range(h): -                binary[j][k] += 1 +            W[j] = 0 -        for j in range(w): -            for k in range(y): -                binary[j][k] += 1 +        for j in range(y): +            H[j] = 0 -        for j in range(w): -            for k in range(y, h): -                binary[j][k] += 1 -total = 0 -for i in range(len(binary)): -    total += binary[i].count(0) -print(total) +        for j in range(y, h): +            H[j] = 0 +print((sum(W) * sum(H)))