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

xya = [list(map(int, input().split())) for _ in range(n)]



field = [[1 for _ in range(w)] for _ in range(h)]



for x, y, a in xya:

        for i in range(h):

             for j in range(w):

                    if a == 1 and j < x:

                        field[i][j] = 0

                    if a == 2 and j >= x:

                        field[i][j] = 0

                    if a == 3 and i < y:

                        field[i][j] = 0

                    if a == 4 and i >= y:

                        field[i][j] = 0



ans = 0

for i in field:

    ans += sum(i)

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

xya = [list(map(int, input().split())) for _ in range(n)]



w1 = 0

w2 = w

h1 = 0

h2 = h

for x, y, a in xya:

    if a == 1:

        w1= max(w1, x)

    if a == 2:

        w2 = min(w2, x)

    if a == 3:

        h1 = max(h1, y)

    if a == 4:

        h2 = min(h2, y)

        

print((max(0, (w2-w1))*max(0, (h2-h1))))
w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
field = [[1 for _ in range(w)] for _ in range(h)]
for x, y, a in xya:
    for i in range(h):
        for j in range(w):
            if a == 1 and j < x:
                field[i][j] = 0
            if a == 2 and j >= x:
                field[i][j] = 0
            if a == 3 and i < y:
                field[i][j] = 0
            if a == 4 and i >= y:
                field[i][j] = 0
ans = 0
for i in field:
    ans += sum(i)
print(ans)

w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
w1 = 0
w2 = w
h1 = 0
h2 = h
for x, y, a in xya:
    if a == 1:
        w1 = max(w1, x)
    if a == 2:
        w2 = min(w2, x)
    if a == 3:
        h1 = max(h1, y)
    if a == 4:
        h2 = min(h2, y)
print((max(0, (w2 - w1)) * max(0, (h2 - h1))))

-field = [[1 for _ in range(w)] for _ in range(h)] +w1 = 0 +w2 = w +h1 = 0 +h2 = h -    for i in range(h): -        for j in range(w): -            if a == 1 and j < x: -                field[i][j] = 0 -            if a == 2 and j >= x: -                field[i][j] = 0 -            if a == 3 and i < y: -                field[i][j] = 0 -            if a == 4 and i >= y: -                field[i][j] = 0 -ans = 0 -for i in field: -    ans += sum(i) -print(ans) +    if a == 1: +        w1 = max(w1, x) +    if a == 2: +        w2 = min(w2, x) +    if a == 3: +        h1 = max(h1, y) +    if a == 4: +        h2 = min(h2, y) +print((max(0, (w2 - w1)) * max(0, (h2 - h1))))