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

sq = list(list(True for _ in range(h)) for _ in range(w))##sq[w][h]

for i in range(n):

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

    if a == 1:

        for ix in range(x):

            for iy in range(h):

                sq[ix][iy] = False

    if a == 2:

        for ix in range(x, w):

            for iy in range(h):

                sq[ix][iy] = False

    if a == 3:

        for ix in range(w):

            for iy in range(y):

                sq[ix][iy] = False

    if a == 4:

        for ix in range(w):

            for iy in range(y, h):

                sq[ix][iy] = False

s = 0

for h in range(w):

    s += sq[h].count(True)

print(s)           

        
def main():

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



    xl, xh = 0, W

    yl, yh = 0, H

    for _ in range(N):

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

        if a == 1:

            xl = max(xl, x)

        elif a == 2:

            xh = min(xh, x)

        elif a == 3:

            yl = max(yl, y)

        else:

            yh = min(yh, y)



    s = max(0, xh - xl) * max(0, yh - yl)



    print(s)





if __name__ == '__main__':

    main()

w, h, n = list(map(int, input().split()))
sq = list(list(True for _ in range(h)) for _ in range(w))  ##sq[w][h]
for i in range(n):
    x, y, a = list(map(int, input().split()))
    if a == 1:
        for ix in range(x):
            for iy in range(h):
                sq[ix][iy] = False
    if a == 2:
        for ix in range(x, w):
            for iy in range(h):
                sq[ix][iy] = False
    if a == 3:
        for ix in range(w):
            for iy in range(y):
                sq[ix][iy] = False
    if a == 4:
        for ix in range(w):
            for iy in range(y, h):
                sq[ix][iy] = False
s = 0
for h in range(w):
    s += sq[h].count(True)
print(s)

def main():
    W, H, N = list(map(int, input().split()))
    xl, xh = 0, W
    yl, yh = 0, H
    for _ in range(N):
        x, y, a = list(map(int, input().split()))
        if a == 1:
            xl = max(xl, x)
        elif a == 2:
            xh = min(xh, x)
        elif a == 3:
            yl = max(yl, y)
        else:
            yh = min(yh, y)
    s = max(0, xh - xl) * max(0, yh - yl)
    print(s)


if __name__ == "__main__":
    main()

-w, h, n = list(map(int, input().split())) -sq = list(list(True for _ in range(h)) for _ in range(w))  ##sq[w][h] -for i in range(n): -    x, y, a = list(map(int, input().split())) -    if a == 1: -        for ix in range(x): -            for iy in range(h): -                sq[ix][iy] = False -    if a == 2: -        for ix in range(x, w): -            for iy in range(h): -                sq[ix][iy] = False -    if a == 3: -        for ix in range(w): -            for iy in range(y): -                sq[ix][iy] = False -    if a == 4: -        for ix in range(w): -            for iy in range(y, h): -                sq[ix][iy] = False -s = 0 -for h in range(w): -    s += sq[h].count(True) -print(s) +def main(): +    W, H, N = list(map(int, input().split())) +    xl, xh = 0, W +    yl, yh = 0, H +    for _ in range(N): +        x, y, a = list(map(int, input().split())) +        if a == 1: +            xl = max(xl, x) +        elif a == 2: +            xh = min(xh, x) +        elif a == 3: +            yl = max(yl, y) +        else: +            yh = min(yh, y) +    s = max(0, xh - xl) * max(0, yh - yl) +    print(s) + + +if __name__ == "__main__": +    main()