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

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

X = [0,w]

Y = [0,h]

for x,y,a in xya:

    if a == 1:

        X[0] = max(X[0], x)

    elif a == 2:

        X[1] = min(X[1], x)

    elif a == 3:

        Y[0] = max(Y[0], y)

    else:

        Y[1] = min(Y[1], y)

if X[0] >= X[1] or Y[0] >= Y[1]: print((0))

else: print((abs(X[0]-X[1])*abs(Y[0]-Y[1])))
w,h,n = list(map(int, input().split()))

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

W = [0,w]

H = [0,h]

for x,y,a in xya:

    if a == 1:

        W[0] = max(W[0],x)

    elif a == 2:

        W[1] = min(W[1], x)

    elif a == 3:

        H[0] = max(H[0],y)

    else:

        H[1] = min(H[1], y)



print(((W[1]-W[0])*(H[1]-H[0]) if W[0]<W[1] and H[0]<H[1] else 0))
w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
X = [0, w]
Y = [0, h]
for x, y, a in xya:
    if a == 1:
        X[0] = max(X[0], x)
    elif a == 2:
        X[1] = min(X[1], x)
    elif a == 3:
        Y[0] = max(Y[0], y)
    else:
        Y[1] = min(Y[1], y)
if X[0] >= X[1] or Y[0] >= Y[1]:
    print((0))
else:
    print((abs(X[0] - X[1]) * abs(Y[0] - Y[1])))

w, h, n = list(map(int, input().split()))
xya = [list(map(int, input().split())) for _ in range(n)]
W = [0, w]
H = [0, h]
for x, y, a in xya:
    if a == 1:
        W[0] = max(W[0], x)
    elif a == 2:
        W[1] = min(W[1], x)
    elif a == 3:
        H[0] = max(H[0], y)
    else:
        H[1] = min(H[1], y)
print(((W[1] - W[0]) * (H[1] - H[0]) if W[0] < W[1] and H[0] < H[1] else 0))

-X = [0, w] -Y = [0, h] +W = [0, w] +H = [0, h] -        X[0] = max(X[0], x) +        W[0] = max(W[0], x) -        X[1] = min(X[1], x) +        W[1] = min(W[1], x) -        Y[0] = max(Y[0], y) +        H[0] = max(H[0], y) -        Y[1] = min(Y[1], y) -if X[0] >= X[1] or Y[0] >= Y[1]: -    print((0)) -else: -    print((abs(X[0] - X[1]) * abs(Y[0] - Y[1]))) +        H[1] = min(H[1], y) +print(((W[1] - W[0]) * (H[1] - H[0]) if W[0] < W[1] and H[0] < H[1] else 0))