import numpy as np

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



print((sum(sum(np.array(field)))))
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)
import numpy as np

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
print((sum(sum(np.array(field)))))

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)

-import numpy as np - -print((sum(sum(np.array(field))))) +ans = 0 +for i in field: +    ans += sum(i) +print(ans)