W, H, N = map(int, input().split())
P = [list(map(int, input().split())) for i in range(N)]
X1, X2, Y1, Y2 = 0, W, 0, H

for i in range(N):
    if P[i][2] == 1:  # ai=1
        X1 = max(X1, P[i][0])
    elif P[i][2] == 2:  # ai=2
        X2 = min(X2, P[i][0])
    elif P[i][2] == 3:  # ai=3
        Y1 = max(Y1, P[i][1])
    elif P[i][2] == 4:  # ai=4
        Y2 = min(Y2, P[i][1])

if X1 < X2 and Y1 < Y2:
    S = (X2 - X1) * (Y2 - Y1)
else:
    S = 0
print(S)