W,H,N = [int(i) for i in input().split()]

rect = [[0]*W for _ in range(H)]

for _ in range(N):

  x,y,a = [int(i) for i in input().split()]

  if a==1:

    for w in range(x):

      for h in range(H):

        rect[h][w]=1

  elif a==2:

    for w in range(x,W):

      for h in range(H):

        rect[h][w]=1

  elif a==3:

    for w in range(W):

      for h in range(y):

        rect[h][w]=1    

  elif a==4:

    for w in range(W):

      for h in range(y,H):

        rect[h][w]=1

ans = 0

for w in range(W):

  for h in range(H):

    if rect[h][w]==0:

      ans+=1

print(ans)
W, H, N = [int(i) for i in input().split()]

top, bottom, left, right = H, 0, 0, W

for _ in range(N):

    x, y, a = [int(i) for i in input().split()]

    if a == 1:

        left = max(left, x)

    elif a == 2:

        right = min(right, x)

    elif a == 3:

        bottom = max(bottom, y)

    elif a == 4:

        top = min(top, y)

print((max(right - left, 0) * max(top - bottom, 0)))
W, H, N = [int(i) for i in input().split()]
rect = [[0] * W for _ in range(H)]
for _ in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        for w in range(x):
            for h in range(H):
                rect[h][w] = 1
    elif a == 2:
        for w in range(x, W):
            for h in range(H):
                rect[h][w] = 1
    elif a == 3:
        for w in range(W):
            for h in range(y):
                rect[h][w] = 1
    elif a == 4:
        for w in range(W):
            for h in range(y, H):
                rect[h][w] = 1
ans = 0
for w in range(W):
    for h in range(H):
        if rect[h][w] == 0:
            ans += 1
print(ans)

W, H, N = [int(i) for i in input().split()]
top, bottom, left, right = H, 0, 0, W
for _ in range(N):
    x, y, a = [int(i) for i in input().split()]
    if a == 1:
        left = max(left, x)
    elif a == 2:
        right = min(right, x)
    elif a == 3:
        bottom = max(bottom, y)
    elif a == 4:
        top = min(top, y)
print((max(right - left, 0) * max(top - bottom, 0)))

-rect = [[0] * W for _ in range(H)] +top, bottom, left, right = H, 0, 0, W -        for w in range(x): -            for h in range(H): -                rect[h][w] = 1 +        left = max(left, x) -        for w in range(x, W): -            for h in range(H): -                rect[h][w] = 1 +        right = min(right, x) -        for w in range(W): -            for h in range(y): -                rect[h][w] = 1 +        bottom = max(bottom, y) -        for w in range(W): -            for h in range(y, H): -                rect[h][w] = 1 -ans = 0 -for w in range(W): -    for h in range(H): -        if rect[h][w] == 0: -            ans += 1 -print(ans) +        top = min(top, y) +print((max(right - left, 0) * max(top - bottom, 0)))