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

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



xy=[['.' for i in range(w)] for i in range(h)]



for x,y,a in l:

  x-=1

  y-=1



  if a==1:

    for i in range(h):

      for j in range(w):

        if j<=x:

          xy[i][j]='#'

  if a==2:

    for i in range(h):

      for j in range(w):

        if x<j:

          xy[i][j]='#'

  if a==3:

    for i in range(h):

      for j in range(w):

        if i<=y:

          xy[i][j]='#'

  if a==4:

    for i in range(h):

      for j in range(w):

        if y<i:

          xy[i][j]='#'



cnt=0

for i in xy:

  cnt+=i.count('.')

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



y_min = 0

y_max = h



x_min = 0

x_max = w



for i in range(n):

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



  if a == 1:

    x_min = max(x_min, x)



  if a == 2:

    x_max = min(x_max, x)



  if a == 3:

    y_min = max(y_min, y)



  if a == 4:

    y_max = min(y_max, y)



white = (y_max - y_min) * (x_max - x_min)

if (y_max - y_min)>=0 and (x_max - x_min)>=0:

  print((max(white, 0)))

else:

  print((0))
w, h, n = list(map(int, input().split()))
l = [list(map(int, input().split())) for i in range(n)]
xy = [["." for i in range(w)] for i in range(h)]
for x, y, a in l:
    x -= 1
    y -= 1
    if a == 1:
        for i in range(h):
            for j in range(w):
                if j <= x:
                    xy[i][j] = "#"
    if a == 2:
        for i in range(h):
            for j in range(w):
                if x < j:
                    xy[i][j] = "#"
    if a == 3:
        for i in range(h):
            for j in range(w):
                if i <= y:
                    xy[i][j] = "#"
    if a == 4:
        for i in range(h):
            for j in range(w):
                if y < i:
                    xy[i][j] = "#"
cnt = 0
for i in xy:
    cnt += i.count(".")
print(cnt)

w, h, n = list(map(int, input().split()))
y_min = 0
y_max = h
x_min = 0
x_max = w
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        x_min = max(x_min, x)
    if a == 2:
        x_max = min(x_max, x)
    if a == 3:
        y_min = max(y_min, y)
    if a == 4:
        y_max = min(y_max, y)
white = (y_max - y_min) * (x_max - x_min)
if (y_max - y_min) >= 0 and (x_max - x_min) >= 0:
    print((max(white, 0)))
else:
    print((0))

-l = [list(map(int, input().split())) for i in range(n)] -xy = [["." for i in range(w)] for i in range(h)] -for x, y, a in l: -    x -= 1 -    y -= 1 +y_min = 0 +y_max = h +x_min = 0 +x_max = w +for i in range(n): +    x, y, a = list(map(int, input().split())) -        for i in range(h): -            for j in range(w): -                if j <= x: -                    xy[i][j] = "#" +        x_min = max(x_min, x) -        for i in range(h): -            for j in range(w): -                if x < j: -                    xy[i][j] = "#" +        x_max = min(x_max, x) -        for i in range(h): -            for j in range(w): -                if i <= y: -                    xy[i][j] = "#" +        y_min = max(y_min, y) -        for i in range(h): -            for j in range(w): -                if y < i: -                    xy[i][j] = "#" -cnt = 0 -for i in xy: -    cnt += i.count(".") -print(cnt) +        y_max = min(y_max, y) +white = (y_max - y_min) * (x_max - x_min) +if (y_max - y_min) >= 0 and (x_max - x_min) >= 0: +    print((max(white, 0))) +else: +    print((0))