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

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



pic = [[1 for _ in range(w)] for _ in range(h)]



for x, y, a in coords:

    if a == 1:

        for row in pic:

            for i in range(x):

                row[i] = 0



    elif a == 2:

        for row in pic:

            for i in range(x, w):

                row[i] = 0



    elif a == 3:

        for i in range(y):

            for j in range(w):

                pic[i][j] = 0



    elif a == 4:

        for i in range(y, h):

            for j in range(w):

                pic[i][j] = 0

    



print((sum(sum(i) for i in pic)))

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

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



minx, maxx = 0, w

miny, maxy = 0, h



for x, y, a  in coords:

    if a == 1:

        minx = max(minx, x)

    elif a == 2:

        maxx = min(maxx, x)

    elif a == 3:

        miny = max(miny, y)

    elif a == 4:

        maxy = min(maxy, y)



if minx > maxx or miny > maxy:

    print((0))

else:

    print(((maxx-minx)*(maxy-miny)))

w, h, n = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ in range(n)]
pic = [[1 for _ in range(w)] for _ in range(h)]
for x, y, a in coords:
    if a == 1:
        for row in pic:
            for i in range(x):
                row[i] = 0
    elif a == 2:
        for row in pic:
            for i in range(x, w):
                row[i] = 0
    elif a == 3:
        for i in range(y):
            for j in range(w):
                pic[i][j] = 0
    elif a == 4:
        for i in range(y, h):
            for j in range(w):
                pic[i][j] = 0
print((sum(sum(i) for i in pic)))

w, h, n = list(map(int, input().split()))
coords = [list(map(int, input().split())) for _ in range(n)]
minx, maxx = 0, w
miny, maxy = 0, h
for x, y, a in coords:
    if a == 1:
        minx = max(minx, x)
    elif a == 2:
        maxx = min(maxx, x)
    elif a == 3:
        miny = max(miny, y)
    elif a == 4:
        maxy = min(maxy, y)
if minx > maxx or miny > maxy:
    print((0))
else:
    print(((maxx - minx) * (maxy - miny)))

-pic = [[1 for _ in range(w)] for _ in range(h)] +minx, maxx = 0, w +miny, maxy = 0, h -        for row in pic: -            for i in range(x): -                row[i] = 0 +        minx = max(minx, x) -        for row in pic: -            for i in range(x, w): -                row[i] = 0 +        maxx = min(maxx, x) -        for i in range(y): -            for j in range(w): -                pic[i][j] = 0 +        miny = max(miny, y) -        for i in range(y, h): -            for j in range(w): -                pic[i][j] = 0 -print((sum(sum(i) for i in pic))) +        maxy = min(maxy, y) +if minx > maxx or miny > maxy: +    print((0)) +else: +    print(((maxx - minx) * (maxy - miny)))