w, h, n = map(int, input().split())
wz = 0
hz = 0
for i in range (n):
    x, y, a = map(int, input().split())
    if a == 1:
        wz = x
    if a == 2:
        w = x
    if a == 3:
        hz = y
    if a == 4:
        h = y
if wz < w or hz < h:
    print((w-wz)*(h-hz))
else:
    print(0)