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



area = [[0 for i in range(w)] for j in range(h)]



for i in range(n):

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



    if a == 1:

        for j in range(0, h):

            for k in range(0, x):

                area[j][k] = 1

    elif a == 2:

        for j in range(0, h):

            for k in range(x, w):

                area[j][k] = 1

    elif a == 3:

        for j in range(0, y):

            for k in range(0, w):

                area[j][k] = 1

    else:

        for j in range(y, h):

            for k in range(0, w):

                area[j][k] = 1



ans = 0

for i in range(h):

    for j in range(w):

        if area[i][j] == 0: ans += 1



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



l = 0

r = w

d = 0

u = h



for i in range(n):

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

    if a == 1: l = max(l, x)

    if a == 2: r = min(r, x)

    if a == 3: d = max(d, y)

    if a == 4: u = min(u, y)



ans = max(0, r - l) * max(0, u - d)



print(ans)
w, h, n = list(map(int, input().split()))
area = [[0 for i in range(w)] for j in range(h)]
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for j in range(0, h):
            for k in range(0, x):
                area[j][k] = 1
    elif a == 2:
        for j in range(0, h):
            for k in range(x, w):
                area[j][k] = 1
    elif a == 3:
        for j in range(0, y):
            for k in range(0, w):
                area[j][k] = 1
    else:
        for j in range(y, h):
            for k in range(0, w):
                area[j][k] = 1
ans = 0
for i in range(h):
    for j in range(w):
        if area[i][j] == 0:
            ans += 1
print(ans)

w, h, n = list(map(int, input().split()))
l = 0
r = w
d = 0
u = h
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        l = max(l, x)
    if a == 2:
        r = min(r, x)
    if a == 3:
        d = max(d, y)
    if a == 4:
        u = min(u, y)
ans = max(0, r - l) * max(0, u - d)
print(ans)

-area = [[0 for i in range(w)] for j in range(h)] +l = 0 +r = w +d = 0 +u = h -        for j in range(0, h): -            for k in range(0, x): -                area[j][k] = 1 -    elif a == 2: -        for j in range(0, h): -            for k in range(x, w): -                area[j][k] = 1 -    elif a == 3: -        for j in range(0, y): -            for k in range(0, w): -                area[j][k] = 1 -    else: -        for j in range(y, h): -            for k in range(0, w): -                area[j][k] = 1 -ans = 0 -for i in range(h): -    for j in range(w): -        if area[i][j] == 0: -            ans += 1 +        l = max(l, x) +    if a == 2: +        r = min(r, x) +    if a == 3: +        d = max(d, y) +    if a == 4: +        u = min(u, y) +ans = max(0, r - l) * max(0, u - d)