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

x = [0] * N
y = [0] * N
a = [0] * N

for i in range(N):
    x[i], y[i], a[i] = map(int, input().split())

X1 = 0
X2 = 0
Y1 = 0
Y2 = 0

x1, x2, y1, y2 = 0, 0, 0, 0

X = 0
Y = 0

entire = W * H

for i in range(N):
    if a[i]==1 and X1<x[i]:
        x1 = x[i] * H
        X1 += x[i]
    elif a[i]==2 and X2<(W-x[i]):
        x2 = (W-x[i]) * H
        X2 += W - x[i]
    elif a[i]==3 and Y1<y[i]:
        y1 = y[i] * W
        Y1 += y[i]
    elif a[i]==4 and Y2<(H-y[i]):
        y2 = (H-y[i]) * W
        Y2 += H - y[i]

entire = entire - (x1 + x2 + y1 + y2) + ((X1+X2) * (Y1+Y2))

print(entire)
