def main():

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

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



    for _ in range(n):

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

        if a == 1:

            for i in range(h):

                for j in range(x):

                    f[i][j] = 0

        if a == 2:

            for i in range(h):

                for j in range(x, w):

                    f[i][j] = 0

        if a == 3:

            for i in range(h - y, h):

                for j in range(w):

                    f[i][j] = 0

        if a == 4:

            for i in range(h - y):

                for j in range(w):

                    f[i][j] = 0



    ans = 0

    for l in f:

        ans += sum(l)

    print(ans)



if __name__ == '__main__':

    main()

from collections import defaultdict





def main():

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

    field = [[1] * W for _ in range(H)]

    for _ in range(N):

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

        y_s, y_e = 0, H

        x_s, x_e = 0, W

        if a == 1:

            x_s, x_e = 0, x

        elif a == 2:

            x_s, x_e = x, W

        elif a == 3:

            y_s, y_e = H - y, H

        elif a == 4:

            y_s, y_e = 0, H - y



        for y in range(y_s, y_e):

            for x in range(x_s, x_e):

                field[y][x] = 0



    print((sum([sum(line) for line in field])))



if __name__ == '__main__':

    main()

def main():
    w, h, n = list(map(int, input().split()))
    f = [[1] * w for _ in range(h)]
    for _ in range(n):
        x, y, a = list(map(int, input().split()))
        if a == 1:
            for i in range(h):
                for j in range(x):
                    f[i][j] = 0
        if a == 2:
            for i in range(h):
                for j in range(x, w):
                    f[i][j] = 0
        if a == 3:
            for i in range(h - y, h):
                for j in range(w):
                    f[i][j] = 0
        if a == 4:
            for i in range(h - y):
                for j in range(w):
                    f[i][j] = 0
    ans = 0
    for l in f:
        ans += sum(l)
    print(ans)


if __name__ == "__main__":
    main()

from collections import defaultdict


def main():
    W, H, N = list(map(int, input().split()))
    field = [[1] * W for _ in range(H)]
    for _ in range(N):
        x, y, a = list(map(int, input().split()))
        y_s, y_e = 0, H
        x_s, x_e = 0, W
        if a == 1:
            x_s, x_e = 0, x
        elif a == 2:
            x_s, x_e = x, W
        elif a == 3:
            y_s, y_e = H - y, H
        elif a == 4:
            y_s, y_e = 0, H - y
        for y in range(y_s, y_e):
            for x in range(x_s, x_e):
                field[y][x] = 0
    print((sum([sum(line) for line in field])))


if __name__ == "__main__":
    main()

+from collections import defaultdict + + -    w, h, n = list(map(int, input().split())) -    f = [[1] * w for _ in range(h)] -    for _ in range(n): +    W, H, N = list(map(int, input().split())) +    field = [[1] * W for _ in range(H)] +    for _ in range(N): +        y_s, y_e = 0, H +        x_s, x_e = 0, W -            for i in range(h): -                for j in range(x): -                    f[i][j] = 0 -        if a == 2: -            for i in range(h): -                for j in range(x, w): -                    f[i][j] = 0 -        if a == 3: -            for i in range(h - y, h): -                for j in range(w): -                    f[i][j] = 0 -        if a == 4: -            for i in range(h - y): -                for j in range(w): -                    f[i][j] = 0 -    ans = 0 -    for l in f: -        ans += sum(l) -    print(ans) +            x_s, x_e = 0, x +        elif a == 2: +            x_s, x_e = x, W +        elif a == 3: +            y_s, y_e = H - y, H +        elif a == 4: +            y_s, y_e = 0, H - y +        for y in range(y_s, y_e): +            for x in range(x_s, x_e): +                field[y][x] = 0 +    print((sum([sum(line) for line in field])))