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



li=[[1 for w in range(W)] for h in range(H)]



for n in range(N):

  X,Y,a=list(map(int,input().split()))

  if a==1:

    for y in range(H):

      for x in range(X):

        li[y][x]=0

  elif a==3:

    for y in range(Y):

      for x in range(W):

        li[y][x]=0

  elif a==2:

    for y in range(H):

      for x in range(X,W):

        li[y][x]=0

  else:

    for y in range(Y,H):

      for x in range(W):

        li[y][x]=0



ans=sum(x.count(1) for x in li)



print(ans)

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

p = [0,w,0,h]

for i in range(n):

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

    if a == 1:

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

    if a == 2:

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

    if a == 3:

        p[2] = max(y,p[2])

    if a == 4:

        p[3] = min(y,p[3])

print((max(0,p[1]-p[0])*max(0,p[3]-p[2])))

W, H, N = list(map(int, input().split()))
li = [[1 for w in range(W)] for h in range(H)]
for n in range(N):
    X, Y, a = list(map(int, input().split()))
    if a == 1:
        for y in range(H):
            for x in range(X):
                li[y][x] = 0
    elif a == 3:
        for y in range(Y):
            for x in range(W):
                li[y][x] = 0
    elif a == 2:
        for y in range(H):
            for x in range(X, W):
                li[y][x] = 0
    else:
        for y in range(Y, H):
            for x in range(W):
                li[y][x] = 0
ans = sum(x.count(1) for x in li)
print(ans)

w, h, n = list(map(int, input().split()))
p = [0, w, 0, h]
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        p[0] = max(x, p[0])
    if a == 2:
        p[1] = min(x, p[1])
    if a == 3:
        p[2] = max(y, p[2])
    if a == 4:
        p[3] = min(y, p[3])
print((max(0, p[1] - p[0]) * max(0, p[3] - p[2])))

-W, H, N = list(map(int, input().split())) -li = [[1 for w in range(W)] for h in range(H)] -for n in range(N): -    X, Y, a = list(map(int, input().split())) +w, h, n = list(map(int, input().split())) +p = [0, w, 0, h] +for i in range(n): +    x, y, a = list(map(int, input().split())) -        for y in range(H): -            for x in range(X): -                li[y][x] = 0 -    elif a == 3: -        for y in range(Y): -            for x in range(W): -                li[y][x] = 0 -    elif a == 2: -        for y in range(H): -            for x in range(X, W): -                li[y][x] = 0 -    else: -        for y in range(Y, H): -            for x in range(W): -                li[y][x] = 0 -ans = sum(x.count(1) for x in li) -print(ans) +        p[0] = max(x, p[0]) +    if a == 2: +        p[1] = min(x, p[1]) +    if a == 3: +        p[2] = max(y, p[2]) +    if a == 4: +        p[3] = min(y, p[3]) +print((max(0, p[1] - p[0]) * max(0, p[3] - p[2])))