def main():

    W, H, N = (int(i) for i in input().split())

    seen = [[True]*W for _ in range(H)]

    for i in range(N):

        X, Y, a = (int(i) for i in input().split())

        if a == 1:

            for h in range(H):

                for x in range(X):

                    seen[h][x] = False

        elif a == 2:

            for h in range(H):

                for x in range(X, W):

                    seen[h][x] = False

        elif a == 3:

            for w in range(W):

                for y in range(Y):

                    seen[y][w] = False

        else:

            for w in range(W):

                for y in range(Y, H):

                    seen[y][w] = False

    # print(*seen, sep="\n")

    ans = 0

    for h in range(H):

        for w in range(W):

            if seen[h][w]:

                ans += 1

    print(ans)





if __name__ == '__main__':

    main()

def main():

    import sys

    input = sys.stdin.buffer.readline

    W, H, N = (int(i) for i in input().split())

    XYA = [[int(i) for i in input().split()] for j in range(N)]

    seen = [[True]*W for _ in range(H)]

    for x, y, a in XYA:

        if a == 1:

            for h in range(H):

                for w in range(x):

                    seen[h][w] = False

        elif a == 2:

            for h in range(H):

                for w in range(x, W):

                    seen[h][w] = False

        elif a == 3:

            for h in range(y):

                for w in range(W):

                    seen[h][w] = False

        elif a == 4:

            for h in range(y, H):

                for w in range(W):

                    seen[h][w] = False

    ans = 0

    for h in range(H):

        for w in range(W):

            if seen[h][w]:

                ans += 1



    print(ans)





if __name__ == '__main__':

    main()

def main():
    W, H, N = (int(i) for i in input().split())
    seen = [[True] * W for _ in range(H)]
    for i in range(N):
        X, Y, a = (int(i) for i in input().split())
        if a == 1:
            for h in range(H):
                for x in range(X):
                    seen[h][x] = False
        elif a == 2:
            for h in range(H):
                for x in range(X, W):
                    seen[h][x] = False
        elif a == 3:
            for w in range(W):
                for y in range(Y):
                    seen[y][w] = False
        else:
            for w in range(W):
                for y in range(Y, H):
                    seen[y][w] = False
    # print(*seen, sep="\n")
    ans = 0
    for h in range(H):
        for w in range(W):
            if seen[h][w]:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

def main():
    import sys

    input = sys.stdin.buffer.readline
    W, H, N = (int(i) for i in input().split())
    XYA = [[int(i) for i in input().split()] for j in range(N)]
    seen = [[True] * W for _ in range(H)]
    for x, y, a in XYA:
        if a == 1:
            for h in range(H):
                for w in range(x):
                    seen[h][w] = False
        elif a == 2:
            for h in range(H):
                for w in range(x, W):
                    seen[h][w] = False
        elif a == 3:
            for h in range(y):
                for w in range(W):
                    seen[h][w] = False
        elif a == 4:
            for h in range(y, H):
                for w in range(W):
                    seen[h][w] = False
    ans = 0
    for h in range(H):
        for w in range(W):
            if seen[h][w]:
                ans += 1
    print(ans)


if __name__ == "__main__":
    main()

+    import sys + +    input = sys.stdin.buffer.readline +    XYA = [[int(i) for i in input().split()] for j in range(N)] -    for i in range(N): -        X, Y, a = (int(i) for i in input().split()) +    for x, y, a in XYA: -                for x in range(X): -                    seen[h][x] = False +                for w in range(x): +                    seen[h][w] = False -                for x in range(X, W): -                    seen[h][x] = False +                for w in range(x, W): +                    seen[h][w] = False -            for w in range(W): -                for y in range(Y): -                    seen[y][w] = False -        else: -            for w in range(W): -                for y in range(Y, H): -                    seen[y][w] = False -    # print(*seen, sep="\n") +            for h in range(y): +                for w in range(W): +                    seen[h][w] = False +        elif a == 4: +            for h in range(y, H): +                for w in range(W): +                    seen[h][w] = False