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

rectangle = [[1 for i in range(W)] for j in range(H)]



def paint(x,y,a):

    if a == 1:

        for i in range(x):

            for j in range(H):

                rectangle[j][i] = 0

    if a == 2:

        for i in range(x,W):

            for j in range(H):

                rectangle[j][i] = 0

    if a == 3:

        for i in range(W):

            for j in range(y):

                rectangle[j][i] = 0

    if a == 4:

        for i in range(W):

            for j in range(y,H):

                rectangle[j][i] = 0





for i in range(N):

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

    paint(x,y,a)

ans = 0

for line in rectangle:

    ans += line.count(1)

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

minx,maxx,miny,maxy = 0,W,0,H

for i in range(N):

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

    if a == 1:

        minx = max(x,minx)

    if a == 2:

        maxx = min(x,maxx)

    if a == 3:

        miny = max(y,miny)

    if a == 4:

        maxy = min(y,maxy)

print((max(0, maxx - minx) * max(0, maxy - miny)))
W, H, N = list(map(int, input().split()))
rectangle = [[1 for i in range(W)] for j in range(H)]


def paint(x, y, a):
    if a == 1:
        for i in range(x):
            for j in range(H):
                rectangle[j][i] = 0
    if a == 2:
        for i in range(x, W):
            for j in range(H):
                rectangle[j][i] = 0
    if a == 3:
        for i in range(W):
            for j in range(y):
                rectangle[j][i] = 0
    if a == 4:
        for i in range(W):
            for j in range(y, H):
                rectangle[j][i] = 0


for i in range(N):
    x, y, a = list(map(int, input().split()))
    paint(x, y, a)
ans = 0
for line in rectangle:
    ans += line.count(1)
print(ans)

W, H, N = list(map(int, input().split()))
minx, maxx, miny, maxy = 0, W, 0, H
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        minx = max(x, minx)
    if a == 2:
        maxx = min(x, maxx)
    if a == 3:
        miny = max(y, miny)
    if a == 4:
        maxy = min(y, maxy)
print((max(0, maxx - minx) * max(0, maxy - miny)))

-rectangle = [[1 for i in range(W)] for j in range(H)] - - -def paint(x, y, a): -    if a == 1: -        for i in range(x): -            for j in range(H): -                rectangle[j][i] = 0 -    if a == 2: -        for i in range(x, W): -            for j in range(H): -                rectangle[j][i] = 0 -    if a == 3: -        for i in range(W): -            for j in range(y): -                rectangle[j][i] = 0 -    if a == 4: -        for i in range(W): -            for j in range(y, H): -                rectangle[j][i] = 0 - - +minx, maxx, miny, maxy = 0, W, 0, H -    paint(x, y, a) -ans = 0 -for line in rectangle: -    ans += line.count(1) -print(ans) +    if a == 1: +        minx = max(x, minx) +    if a == 2: +        maxx = min(x, maxx) +    if a == 3: +        miny = max(y, miny) +    if a == 4: +        maxy = min(y, maxy) +print((max(0, maxx - minx) * max(0, maxy - miny)))