import numpy as np



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



xl = 0

xr = W

yu = H

yd = 0



for i in range(N):

    x,y,a = list(map(int, input().split()))



    if a == 1:

        xl = max(xl,x)

    elif a == 2:

        xr = min(xr,x)

    elif a == 3:

        yd = max(yd,y)

    else:

        yu = min(yu,y)



ans = max(0,xr - xl) * max(0,yu - yd)



print(ans)

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



xl = 0

xr = W

yu = H

yd = 0



for i in range(N):

    x,y,a = list(map(int, input().split()))



    if a == 1:

        xl = max(xl,x)

    elif a == 2:

        xr = min(xr,x)

    elif a == 3:

        yd = max(yd,y)

    else:

        yu = min(yu,y)



ans = max(0,xr - xl) * max(0,yu - yd)



print(ans)

import numpy as np

W, H, N = list(map(int, input().split()))
xl = 0
xr = W
yu = H
yd = 0
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        xl = max(xl, x)
    elif a == 2:
        xr = min(xr, x)
    elif a == 3:
        yd = max(yd, y)
    else:
        yu = min(yu, y)
ans = max(0, xr - xl) * max(0, yu - yd)
print(ans)

W, H, N = list(map(int, input().split()))
xl = 0
xr = W
yu = H
yd = 0
for i in range(N):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        xl = max(xl, x)
    elif a == 2:
        xr = min(xr, x)
    elif a == 3:
        yd = max(yd, y)
    else:
        yu = min(yu, y)
ans = max(0, xr - xl) * max(0, yu - yd)
print(ans)

-import numpy as np -