import numpy as np

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

x = []

y = []

a = []

for _ in range(N):

    b, c, d = list(map(int, input().split()))

    x.append(b)

    y.append(c)

    a.append(d)

A = np.zeros((H, W))



for i in range(N):

    if a[i] == 1:

        for j in range(x[i]):

            for k in range(H):

                A[k][j] = 1

    elif a[i] == 2:

        for j in range(x[i],W):

            for k in range(H):

                A[k][j] = 1

    elif a[i] == 3:

        for j in range(y[i]):

            for k in range(W):

                A[j][k] = 1

    elif a[i] == 4:

        for j in range(y[i], H):

            for k in range(W):

                A[j][k] = 1



print((np.sum(A==0)))

import numpy as np

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

xy = np.zeros((w,h))

xya = [[int(a) for a in input().split()] for _ in range(n)]

for i in range(n):

    if xya[i][2]==1:

        for x in range(xya[i][0]):

            xy[x][:h] = 1

    elif xya[i][2] == 2:

        for x in range(xya[i][0], w):

            xy[x][:h] = 1

    elif xya[i][2]==3:

        for x in range(w):

            for y in range(xya[i][1]):

                xy[x][y] = 1

    elif xya[i][2] == 4:

        for x in range(w):

            for y in range(xya[i][1], h):

                xy[x][y] = 1

wh = [int(item) for wh in xy for item in wh]

print((wh.count(0)))
import numpy as np

W, H, N = list(map(int, input().split()))
x = []
y = []
a = []
for _ in range(N):
    b, c, d = list(map(int, input().split()))
    x.append(b)
    y.append(c)
    a.append(d)
A = np.zeros((H, W))
for i in range(N):
    if a[i] == 1:
        for j in range(x[i]):
            for k in range(H):
                A[k][j] = 1
    elif a[i] == 2:
        for j in range(x[i], W):
            for k in range(H):
                A[k][j] = 1
    elif a[i] == 3:
        for j in range(y[i]):
            for k in range(W):
                A[j][k] = 1
    elif a[i] == 4:
        for j in range(y[i], H):
            for k in range(W):
                A[j][k] = 1
print((np.sum(A == 0)))

import numpy as np

w, h, n = list(map(int, input().split()))
xy = np.zeros((w, h))
xya = [[int(a) for a in input().split()] for _ in range(n)]
for i in range(n):
    if xya[i][2] == 1:
        for x in range(xya[i][0]):
            xy[x][:h] = 1
    elif xya[i][2] == 2:
        for x in range(xya[i][0], w):
            xy[x][:h] = 1
    elif xya[i][2] == 3:
        for x in range(w):
            for y in range(xya[i][1]):
                xy[x][y] = 1
    elif xya[i][2] == 4:
        for x in range(w):
            for y in range(xya[i][1], h):
                xy[x][y] = 1
wh = [int(item) for wh in xy for item in wh]
print((wh.count(0)))

-W, H, N = list(map(int, input().split())) -x = [] -y = [] -a = [] -for _ in range(N): -    b, c, d = list(map(int, input().split())) -    x.append(b) -    y.append(c) -    a.append(d) -A = np.zeros((H, W)) -for i in range(N): -    if a[i] == 1: -        for j in range(x[i]): -            for k in range(H): -                A[k][j] = 1 -    elif a[i] == 2: -        for j in range(x[i], W): -            for k in range(H): -                A[k][j] = 1 -    elif a[i] == 3: -        for j in range(y[i]): -            for k in range(W): -                A[j][k] = 1 -    elif a[i] == 4: -        for j in range(y[i], H): -            for k in range(W): -                A[j][k] = 1 -print((np.sum(A == 0))) +w, h, n = list(map(int, input().split())) +xy = np.zeros((w, h)) +xya = [[int(a) for a in input().split()] for _ in range(n)] +for i in range(n): +    if xya[i][2] == 1: +        for x in range(xya[i][0]): +            xy[x][:h] = 1 +    elif xya[i][2] == 2: +        for x in range(xya[i][0], w): +            xy[x][:h] = 1 +    elif xya[i][2] == 3: +        for x in range(w): +            for y in range(xya[i][1]): +                xy[x][y] = 1 +    elif xya[i][2] == 4: +        for x in range(w): +            for y in range(xya[i][1], h): +                xy[x][y] = 1 +wh = [int(item) for wh in xy for item in wh] +print((wh.count(0)))