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

paint_dot = {}

for _ in range(N):

  t1, t2, t3 = list(map(int,input().split()))

  paint_dot[(t1, t2)] = t3



mat = [[1]*W for i in range(H)]



for key in paint_dot:

  x = paint_dot[key]

  if x == 1:

    for row in mat:

      for i in range(key[0]):

        row[i] = 0    

  elif x == 2:    

    for row in mat:

      for i in range(key[0], W):

        row[i] = 0

  elif x == 3:

    for i in range(key[1]):

      for j in range(W):

      	mat[i][j] = 0

  else:

    for i in range(key[1], H):

      for j in range(W):

      	mat[i][j] = 0



#print(mat)

print((sum(map(sum,mat))))

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

paint_dot = {}

for _ in range(N):

  t1, t2, t3 = list(map(int,input().split()))

  paint_dot[(t1, t2)] = t3



pattern_H = [1]*H

pattern_W = [1]*W



for key in paint_dot:

  if paint_dot[key] == 1:

    for i in range(key[0]):

      pattern_W[i] = 0

  elif paint_dot[key] == 2:

    for i in range(key[0],W):

      pattern_W[i] = 0

  elif paint_dot[key] == 3:

    for i in range(key[1]):

      pattern_H[i] = 0

  else:

    for i in range(key[1],H):

      pattern_H[i] = 0



print((sum(pattern_W) * sum(pattern_H)))

        
W, H, N = list(map(int, input().split()))
paint_dot = {}
for _ in range(N):
    t1, t2, t3 = list(map(int, input().split()))
    paint_dot[(t1, t2)] = t3
mat = [[1] * W for i in range(H)]
for key in paint_dot:
    x = paint_dot[key]
    if x == 1:
        for row in mat:
            for i in range(key[0]):
                row[i] = 0
    elif x == 2:
        for row in mat:
            for i in range(key[0], W):
                row[i] = 0
    elif x == 3:
        for i in range(key[1]):
            for j in range(W):
                mat[i][j] = 0
    else:
        for i in range(key[1], H):
            for j in range(W):
                mat[i][j] = 0
# print(mat)
print((sum(map(sum, mat))))

W, H, N = list(map(int, input().split()))
paint_dot = {}
for _ in range(N):
    t1, t2, t3 = list(map(int, input().split()))
    paint_dot[(t1, t2)] = t3
pattern_H = [1] * H
pattern_W = [1] * W
for key in paint_dot:
    if paint_dot[key] == 1:
        for i in range(key[0]):
            pattern_W[i] = 0
    elif paint_dot[key] == 2:
        for i in range(key[0], W):
            pattern_W[i] = 0
    elif paint_dot[key] == 3:
        for i in range(key[1]):
            pattern_H[i] = 0
    else:
        for i in range(key[1], H):
            pattern_H[i] = 0
print((sum(pattern_W) * sum(pattern_H)))

-mat = [[1] * W for i in range(H)] +pattern_H = [1] * H +pattern_W = [1] * W -    x = paint_dot[key] -    if x == 1: -        for row in mat: -            for i in range(key[0]): -                row[i] = 0 -    elif x == 2: -        for row in mat: -            for i in range(key[0], W): -                row[i] = 0 -    elif x == 3: +    if paint_dot[key] == 1: +        for i in range(key[0]): +            pattern_W[i] = 0 +    elif paint_dot[key] == 2: +        for i in range(key[0], W): +            pattern_W[i] = 0 +    elif paint_dot[key] == 3: -            for j in range(W): -                mat[i][j] = 0 +            pattern_H[i] = 0 -            for j in range(W): -                mat[i][j] = 0 -# print(mat) -print((sum(map(sum, mat)))) +            pattern_H[i] = 0 +print((sum(pattern_W) * sum(pattern_H)))