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 and w[0] < x:

    w[0] = x

  elif a == 2 and w[1] > x:

    w[1] = x

  elif a == 3 and h[0] < y:

    h[0] = y

  elif a == 4 and h[1] > y:

    h[1] = y



if w[0] < w[1] and h[0] < h[1]:

  print((abs(w[0] - w[1]) * abs(h[0] - h[1])))

else: print((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 and X[0] < x: X[0] = x

    elif a == 2 and X[1] > x: X[1] = x

    elif a == 3 and Y[0] < y: Y[0] = y

    elif a == 4 and Y[1] > y: Y[1] = y

h, w = Y[1]-Y[0], X[1]-X[0]

print((0 if h<0 or w<0 else h*w))
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 and w[0] < x:
        w[0] = x
    elif a == 2 and w[1] > x:
        w[1] = x
    elif a == 3 and h[0] < y:
        h[0] = y
    elif a == 4 and h[1] > y:
        h[1] = y
if w[0] < w[1] and h[0] < h[1]:
    print((abs(w[0] - w[1]) * abs(h[0] - h[1])))
else:
    print((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 and X[0] < x:
        X[0] = x
    elif a == 2 and X[1] > x:
        X[1] = x
    elif a == 3 and Y[0] < y:
        Y[0] = y
    elif a == 4 and Y[1] > y:
        Y[1] = y
h, w = Y[1] - Y[0], X[1] - X[0]
print((0 if h < 0 or w < 0 else h * w))

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