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

X,Y,A = [],[],[]

for i in range(N):

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

    X.append(x)

    Y.append(y)

    A.append(a)

x0,x1,y0,y1 = 0,W,0,H

for i in range(N):

    if A[i]==1:

        x0 = max(x0,X[i])

    elif A[i]==2:

        x1 = min(x1,X[i])

    elif A[i]==3:

        y0 = max(y0,Y[i])

    else:

        y1 = min(y1,Y[i])



print((max(0,(x1-x0))*max(0,(y1-y0))))
# python3 (3.4.3)

import sys

input = sys.stdin.readline



# main

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

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



x_lb,x_ub,y_lb,y_ub = 0,W,0,H



for x,y,a in XYA:

    if a==1:

        x_lb = max(x_lb,x)

    elif a==2:

        x_ub = min(x_ub,x)

    elif a==3:

        y_lb = max(y_lb,y)

    else:

        y_ub = min(y_ub,y)



x = max(0, x_ub - x_lb)

y = max(0, y_ub - y_lb)



print((x*y))
W, H, N = list(map(int, input().split()))
X, Y, A = [], [], []
for i in range(N):
    x, y, a = list(map(int, input().split()))
    X.append(x)
    Y.append(y)
    A.append(a)
x0, x1, y0, y1 = 0, W, 0, H
for i in range(N):
    if A[i] == 1:
        x0 = max(x0, X[i])
    elif A[i] == 2:
        x1 = min(x1, X[i])
    elif A[i] == 3:
        y0 = max(y0, Y[i])
    else:
        y1 = min(y1, Y[i])
print((max(0, (x1 - x0)) * max(0, (y1 - y0))))

# python3 (3.4.3)
import sys

input = sys.stdin.readline
# main
W, H, N = list(map(int, input().split()))
XYA = [list(map(int, input().split())) for _ in range(N)]
x_lb, x_ub, y_lb, y_ub = 0, W, 0, H
for x, y, a in XYA:
    if a == 1:
        x_lb = max(x_lb, x)
    elif a == 2:
        x_ub = min(x_ub, x)
    elif a == 3:
        y_lb = max(y_lb, y)
    else:
        y_ub = min(y_ub, y)
x = max(0, x_ub - x_lb)
y = max(0, y_ub - y_lb)
print((x * y))

+# python3 (3.4.3) +import sys + +input = sys.stdin.readline +# main -X, Y, A = [], [], [] -for i in range(N): -    x, y, a = list(map(int, input().split())) -    X.append(x) -    Y.append(y) -    A.append(a) -x0, x1, y0, y1 = 0, W, 0, H -for i in range(N): -    if A[i] == 1: -        x0 = max(x0, X[i]) -    elif A[i] == 2: -        x1 = min(x1, X[i]) -    elif A[i] == 3: -        y0 = max(y0, Y[i]) +XYA = [list(map(int, input().split())) for _ in range(N)] +x_lb, x_ub, y_lb, y_ub = 0, W, 0, H +for x, y, a in XYA: +    if a == 1: +        x_lb = max(x_lb, x) +    elif a == 2: +        x_ub = min(x_ub, x) +    elif a == 3: +        y_lb = max(y_lb, y) -        y1 = min(y1, Y[i]) -print((max(0, (x1 - x0)) * max(0, (y1 - y0)))) +        y_ub = min(y_ub, y) +x = max(0, x_ub - x_lb) +y = max(0, y_ub - y_lb) +print((x * y))