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

rec = [["W"]*(W) for _ in range(H)]



for _ in range(N):

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

    if a==1:

        for h in range(H):

            for w in range(W):

                if w<x:

                    rec[h][w]="B"

    elif a==2:

        for h in range(H):

            for w in range(W):

                if w>=x:

                    rec[h][w]="B"

    elif a==3:

        for h in range(H):

            for w in range(W):

                if h<y:

                    rec[h][w]="B"

    else:

        for h in range(H):

            for w in range(W):

                if h>=y:

                    rec[h][w]="B"

                    

ans = 0

for h in range(H):

    for w in range(W):

        if rec[h][w]=="W":

            ans += 1

print(ans)

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

x_min, y_min = 0,0

x_max, y_max = W,H

for _ in range(N):

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

    if a==1:

        x_min = max(x_min, x)

    elif a==2:

        x_max = min(x_max, x)

    elif a==3:

        y_min = max(y_min, y)

    else:

        y_max = min(y_max, y)

width = max(0, x_max-x_min)

height = max(0, y_max-y_min)

print((width*height))
W, H, N = list(map(int, input().split()))
rec = [["W"] * (W) for _ in range(H)]
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for h in range(H):
            for w in range(W):
                if w < x:
                    rec[h][w] = "B"
    elif a == 2:
        for h in range(H):
            for w in range(W):
                if w >= x:
                    rec[h][w] = "B"
    elif a == 3:
        for h in range(H):
            for w in range(W):
                if h < y:
                    rec[h][w] = "B"
    else:
        for h in range(H):
            for w in range(W):
                if h >= y:
                    rec[h][w] = "B"
ans = 0
for h in range(H):
    for w in range(W):
        if rec[h][w] == "W":
            ans += 1
print(ans)
# print(rec)

W, H, N = list(map(int, input().split()))
x_min, y_min = 0, 0
x_max, y_max = W, H
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x_min = max(x_min, x)
    elif a == 2:
        x_max = min(x_max, x)
    elif a == 3:
        y_min = max(y_min, y)
    else:
        y_max = min(y_max, y)
width = max(0, x_max - x_min)
height = max(0, y_max - y_min)
print((width * height))

-rec = [["W"] * (W) for _ in range(H)] +x_min, y_min = 0, 0 +x_max, y_max = W, H -        for h in range(H): -            for w in range(W): -                if w < x: -                    rec[h][w] = "B" +        x_min = max(x_min, x) -        for h in range(H): -            for w in range(W): -                if w >= x: -                    rec[h][w] = "B" +        x_max = min(x_max, x) -        for h in range(H): -            for w in range(W): -                if h < y: -                    rec[h][w] = "B" +        y_min = max(y_min, y) -        for h in range(H): -            for w in range(W): -                if h >= y: -                    rec[h][w] = "B" -ans = 0 -for h in range(H): -    for w in range(W): -        if rec[h][w] == "W": -            ans += 1 -print(ans) -# print(rec) +        y_max = min(y_max, y) +width = max(0, x_max - x_min) +height = max(0, y_max - y_min) +print((width * height))