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

cnt = 0

k = [[False for i in range(w)] for j in range(h)]

while(cnt < n):

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

    

    if(a == 1):

        for i in range(h):

            for j in range(x):

                k[i][j] = True

    elif(a == 2):

        for i in range(h):

            for j in range(x,w):

                k[i][j] = True

    elif(a == 3):

        for i in range(y):

            for j in range(w):

                k[i][j] = True

    elif(a == 4):

        for i in range(y,h):

            for j in range(w):

                k[i][j] = True

    cnt += 1

sum = 0

for i in range(h):

    sum += k[i].count(False)

print(sum)
#数学的に解く

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

cnt = 0

X = 0

Y = 0

while(cnt < n):

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

    

    if(a == 1):

        X = max(X,x)

    elif(a == 2):

        w = min(w,x)

    elif(a == 3):

        Y = max(Y,y)

    elif(a == 4):

        h = min(h,y)

    #print(w,h,X,Y)

    cnt += 1

print((max(w-X,0)*max(h-Y,0)))
w, h, n = list(map(int, input().split()))
cnt = 0
k = [[False for i in range(w)] for j in range(h)]
while cnt < n:
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for i in range(h):
            for j in range(x):
                k[i][j] = True
    elif a == 2:
        for i in range(h):
            for j in range(x, w):
                k[i][j] = True
    elif a == 3:
        for i in range(y):
            for j in range(w):
                k[i][j] = True
    elif a == 4:
        for i in range(y, h):
            for j in range(w):
                k[i][j] = True
    cnt += 1
sum = 0
for i in range(h):
    sum += k[i].count(False)
print(sum)

# 数学的に解く
w, h, n = list(map(int, input().split()))
cnt = 0
X = 0
Y = 0
while cnt < n:
    x, y, a = list(map(int, input().split()))
    if a == 1:
        X = max(X, x)
    elif a == 2:
        w = min(w, x)
    elif a == 3:
        Y = max(Y, y)
    elif a == 4:
        h = min(h, y)
    # print(w,h,X,Y)
    cnt += 1
print((max(w - X, 0) * max(h - Y, 0)))

+# 数学的に解く -k = [[False for i in range(w)] for j in range(h)] +X = 0 +Y = 0 -        for i in range(h): -            for j in range(x): -                k[i][j] = True +        X = max(X, x) -        for i in range(h): -            for j in range(x, w): -                k[i][j] = True +        w = min(w, x) -        for i in range(y): -            for j in range(w): -                k[i][j] = True +        Y = max(Y, y) -        for i in range(y, h): -            for j in range(w): -                k[i][j] = True +        h = min(h, y) +    # print(w,h,X,Y) -sum = 0 -for i in range(h): -    sum += k[i].count(False) -print(sum) +print((max(w - X, 0) * max(h - Y, 0)))