W, H, N = map(int, input().split())
x1 = y1 = 0
x2 = W
y2 = H
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    else:
        y2 = min(y2, y)

print(max(0, (x2 - x1)) * max(0, (y2 - y1)))