w,h,n = list(map(int,input().split()))

lists = [list(map(int,input().split())) for i in range(n)]

x1 = 0

x2 = w

y1 = 0

y2 = h

for x,y,a in lists:

    if a == 1:

        x1 = max(x1,x)

    elif a == 2:

        x2 = min(x2,x)

    elif a == 3:

        y1 = max(y1,y)

    elif a == 4:

        y2 = min(y2,y)

x = max(0,(x2 - x1))

y = max(0,(y2 - y1))

ans = max(0,x*y)

print(ans)
w,h,n = list(map(int,input().split()))

lists = [list(map(int,input().split())) for i in range(n)]

plx = 0

ply = 0

prx = w

pry = h

for x,y,a in lists:

    if a == 1:

        if plx < x:

            plx = x

    elif a == 2:

        if prx > x:

            prx = x

    elif a == 3:

        if ply < y:

            ply = y

    elif a == 4:

        if pry > y:

            pry = y

px = (prx - plx)

if px < 0:

    px = 0

py = (pry - ply)

if py < 0:

    py = 0

ans = px * py

if ans < 0:

    ans = 0

print(ans)

w, h, n = list(map(int, input().split()))
lists = [list(map(int, input().split())) for i in range(n)]
x1 = 0
x2 = w
y1 = 0
y2 = h
for x, y, a in lists:
    if a == 1:
        x1 = max(x1, x)
    elif a == 2:
        x2 = min(x2, x)
    elif a == 3:
        y1 = max(y1, y)
    elif a == 4:
        y2 = min(y2, y)
x = max(0, (x2 - x1))
y = max(0, (y2 - y1))
ans = max(0, x * y)
print(ans)

w, h, n = list(map(int, input().split()))
lists = [list(map(int, input().split())) for i in range(n)]
plx = 0
ply = 0
prx = w
pry = h
for x, y, a in lists:
    if a == 1:
        if plx < x:
            plx = x
    elif a == 2:
        if prx > x:
            prx = x
    elif a == 3:
        if ply < y:
            ply = y
    elif a == 4:
        if pry > y:
            pry = y
px = prx - plx
if px < 0:
    px = 0
py = pry - ply
if py < 0:
    py = 0
ans = px * py
if ans < 0:
    ans = 0
print(ans)

-x1 = 0 -x2 = w -y1 = 0 -y2 = h +plx = 0 +ply = 0 +prx = w +pry = h -        x1 = max(x1, x) +        if plx < x: +            plx = x -        x2 = min(x2, x) +        if prx > x: +            prx = x -        y1 = max(y1, y) +        if ply < y: +            ply = y -        y2 = min(y2, y) -x = max(0, (x2 - x1)) -y = max(0, (y2 - y1)) -ans = max(0, x * y) +        if pry > y: +            pry = y +px = prx - plx +if px < 0: +    px = 0 +py = pry - ply +if py < 0: +    py = 0 +ans = px * py +if ans < 0: +    ans = 0