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

cells = [[0 for _ in range(W)] for _ in range(H)]

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



for ls in lists:

    x, y, a = ls[0], ls[1], ls[2]

    if a == 1:

        # xi の左側を塗りつぶす

        for h in range(H):

            for w in range(x):

                cells[h][w] = 1

    elif a == 2:

        # xi の右側を塗りつぶす

        for h in range(H):

            for w in range(x, W):

                cells[h][w] = 1

    elif a == 3:

        # yi の下側を塗りつぶす

        for h in range(H-y, H):

            for w in range(W):

                cells[h][w] = 1

    else:

        # yi の上側を塗りつぶす

        for h in range(H-y):

            for w in range(W):

                cells[h][w] = 1



count = 0

for rows in cells:

    count += rows.count(0)



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

w, h = 0, 0



for _ in range(N):

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

    if a == 1:

        # 黒の領域(x軸)を増やす

        w = max(w, x)

    elif a == 2:

        # 白の領域(x軸)を削る

        W = min(W, x)

    elif a == 3:

        # 黒の領域(y軸)を増やす

        h = max(h, y)

    else:

        # 白の領域(y軸)を削る

        H = min(H, y)



if W < w or H < h:

    print((0))

else:

    print(((W-w)*(H-h)))
W, H, N = list(map(int, input().split()))
cells = [[0 for _ in range(W)] for _ in range(H)]
lists = [list(map(int, input().split())) for _ in range(N)]
for ls in lists:
    x, y, a = ls[0], ls[1], ls[2]
    if a == 1:
        # xi の左側を塗りつぶす
        for h in range(H):
            for w in range(x):
                cells[h][w] = 1
    elif a == 2:
        # xi の右側を塗りつぶす
        for h in range(H):
            for w in range(x, W):
                cells[h][w] = 1
    elif a == 3:
        # yi の下側を塗りつぶす
        for h in range(H - y, H):
            for w in range(W):
                cells[h][w] = 1
    else:
        # yi の上側を塗りつぶす
        for h in range(H - y):
            for w in range(W):
                cells[h][w] = 1
count = 0
for rows in cells:
    count += rows.count(0)
print(count)

W, H, N = list(map(int, input().split()))
w, h = 0, 0
for _ in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        # 黒の領域(x軸)を増やす
        w = max(w, x)
    elif a == 2:
        # 白の領域(x軸)を削る
        W = min(W, x)
    elif a == 3:
        # 黒の領域(y軸)を増やす
        h = max(h, y)
    else:
        # 白の領域(y軸)を削る
        H = min(H, y)
if W < w or H < h:
    print((0))
else:
    print(((W - w) * (H - h)))

-cells = [[0 for _ in range(W)] for _ in range(H)] -lists = [list(map(int, input().split())) for _ in range(N)] -for ls in lists: -    x, y, a = ls[0], ls[1], ls[2] +w, h = 0, 0 +for _ in range(N): +    x, y, a = list(map(int, input().split())) -        # xi の左側を塗りつぶす -        for h in range(H): -            for w in range(x): -                cells[h][w] = 1 +        # 黒の領域(x軸)を増やす +        w = max(w, x) -        # xi の右側を塗りつぶす -        for h in range(H): -            for w in range(x, W): -                cells[h][w] = 1 +        # 白の領域(x軸)を削る +        W = min(W, x) -        # yi の下側を塗りつぶす -        for h in range(H - y, H): -            for w in range(W): -                cells[h][w] = 1 +        # 黒の領域(y軸)を増やす +        h = max(h, y) -        # yi の上側を塗りつぶす -        for h in range(H - y): -            for w in range(W): -                cells[h][w] = 1 -count = 0 -for rows in cells: -    count += rows.count(0) -print(count) +        # 白の領域(y軸)を削る +        H = min(H, y) +if W < w or H < h: +    print((0)) +else: +    print(((W - w) * (H - h)))