w,h,n=input().split()

w,h,n=int(w),int(h),int(n)

s=[[0 for i in range(w)] for j in range(h)]



for i in range(n):

    x,y,a=input().split()

    x,y,a=int(x),int(y),int(a)

    if a==1:

        if x==0:

            pass

        else:

            for j in range(h):

                s[j][:x]=[1 for k in range(x)]

    elif a==2:

        if x==w:

            pass

        else:

            for j in range(h):

                s[j][x:]=[1 for k in range(w-x)]

    elif a==3:

        if y==0:

            pass

        else:

            for j in range(y):

                s[h-j-1]=[1 for k in range(w)]

    else:

        if y==h:

            pass

        else:

            for j in range(h-y):

                s[j]=[1 for k in range(w)]

c=0

for i in range(h):

    for j in range(w):

        if s[i][j]==0:

            c+=1

#print(d)

#print(s)

print(c)

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

a1,a2,a3,a4=0,w,0,h

for i in range(n):

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

    if a==1:

        a1=max(a1,x)

    elif a==2:

        a2=min(a2,x)

    elif a==3:

        a3=max(a3,y)

    else:

        a4=min(a4,y)

print((max(a2-a1,0)*max(a4-a3,0)))
w, h, n = input().split()
w, h, n = int(w), int(h), int(n)
s = [[0 for i in range(w)] for j in range(h)]
for i in range(n):
    x, y, a = input().split()
    x, y, a = int(x), int(y), int(a)
    if a == 1:
        if x == 0:
            pass
        else:
            for j in range(h):
                s[j][:x] = [1 for k in range(x)]
    elif a == 2:
        if x == w:
            pass
        else:
            for j in range(h):
                s[j][x:] = [1 for k in range(w - x)]
    elif a == 3:
        if y == 0:
            pass
        else:
            for j in range(y):
                s[h - j - 1] = [1 for k in range(w)]
    else:
        if y == h:
            pass
        else:
            for j in range(h - y):
                s[j] = [1 for k in range(w)]
c = 0
for i in range(h):
    for j in range(w):
        if s[i][j] == 0:
            c += 1
# print(d)
# print(s)
print(c)

w, h, n = list(map(int, input().split()))
a1, a2, a3, a4 = 0, w, 0, h
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        a1 = max(a1, x)
    elif a == 2:
        a2 = min(a2, x)
    elif a == 3:
        a3 = max(a3, y)
    else:
        a4 = min(a4, y)
print((max(a2 - a1, 0) * max(a4 - a3, 0)))

-w, h, n = input().split() -w, h, n = int(w), int(h), int(n) -s = [[0 for i in range(w)] for j in range(h)] +w, h, n = list(map(int, input().split())) +a1, a2, a3, a4 = 0, w, 0, h -    x, y, a = input().split() -    x, y, a = int(x), int(y), int(a) +    x, y, a = list(map(int, input().split())) -        if x == 0: -            pass -        else: -            for j in range(h): -                s[j][:x] = [1 for k in range(x)] +        a1 = max(a1, x) -        if x == w: -            pass -        else: -            for j in range(h): -                s[j][x:] = [1 for k in range(w - x)] +        a2 = min(a2, x) -        if y == 0: -            pass -        else: -            for j in range(y): -                s[h - j - 1] = [1 for k in range(w)] +        a3 = max(a3, y) -        if y == h: -            pass -        else: -            for j in range(h - y): -                s[j] = [1 for k in range(w)] -c = 0 -for i in range(h): -    for j in range(w): -        if s[i][j] == 0: -            c += 1 -# print(d) -# print(s) -print(c) +        a4 = min(a4, y) +print((max(a2 - a1, 0) * max(a4 - a3, 0)))