import sys

from itertools import accumulate



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def main():

    W, H, N, *XYA = list(map(int, read().split()))



    vec_x = [0] * (W + 1)

    vec_y = [0] * (H + 1)

    for x, y, a in zip(*[iter(XYA)] * 3):

        if a == 1:

            vec_x[0] += 1

            vec_x[x] -= 1

        elif a == 2:

            vec_x[x] += 1

            vec_x[W] -= 1

        elif a == 3:

            vec_y[0] += 1

            vec_y[y] -= 1

        else:

            vec_y[y] += 1

            vec_y[H] -= 1



    vec_x = list(accumulate(vec_x))

    vec_y = list(accumulate(vec_y))



    ans = 0

    for i in range(W):

        for j in range(H):

            if vec_x[i] == 0 and vec_y[j] == 0:

                ans += 1



    print(ans)

    return





if __name__ == '__main__':

    main()

import sys

from itertools import accumulate



read = sys.stdin.read

readline = sys.stdin.readline

readlines = sys.stdin.readlines

sys.setrecursionlimit(10 ** 9)

INF = 1 << 60

MOD = 1000000007





def main():

    W, H, N, *XYA = list(map(int, read().split()))



    x_left = 0

    x_right = W

    y_left = 0

    y_right = H

    for x, y, a in zip(*[iter(XYA)] * 3):

        if a == 1 and x_left < x:

            x_left = x

        elif a == 2 and x_right > x:

            x_right = x

        elif a == 3 and y_left < y:

            y_left = y

        elif a == 4 and y_right > y:

            y_right = y



    print((max(x_right - x_left, 0) * max(y_right - y_left, 0)))

    return





if __name__ == '__main__':

    main()

import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def main():
    W, H, N, *XYA = list(map(int, read().split()))
    vec_x = [0] * (W + 1)
    vec_y = [0] * (H + 1)
    for x, y, a in zip(*[iter(XYA)] * 3):
        if a == 1:
            vec_x[0] += 1
            vec_x[x] -= 1
        elif a == 2:
            vec_x[x] += 1
            vec_x[W] -= 1
        elif a == 3:
            vec_y[0] += 1
            vec_y[y] -= 1
        else:
            vec_y[y] += 1
            vec_y[H] -= 1
    vec_x = list(accumulate(vec_x))
    vec_y = list(accumulate(vec_y))
    ans = 0
    for i in range(W):
        for j in range(H):
            if vec_x[i] == 0 and vec_y[j] == 0:
                ans += 1
    print(ans)
    return


if __name__ == "__main__":
    main()

import sys
from itertools import accumulate

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10**9)
INF = 1 << 60
MOD = 1000000007


def main():
    W, H, N, *XYA = list(map(int, read().split()))
    x_left = 0
    x_right = W
    y_left = 0
    y_right = H
    for x, y, a in zip(*[iter(XYA)] * 3):
        if a == 1 and x_left < x:
            x_left = x
        elif a == 2 and x_right > x:
            x_right = x
        elif a == 3 and y_left < y:
            y_left = y
        elif a == 4 and y_right > y:
            y_right = y
    print((max(x_right - x_left, 0) * max(y_right - y_left, 0)))
    return


if __name__ == "__main__":
    main()

-    vec_x = [0] * (W + 1) -    vec_y = [0] * (H + 1) +    x_left = 0 +    x_right = W +    y_left = 0 +    y_right = H -        if a == 1: -            vec_x[0] += 1 -            vec_x[x] -= 1 -        elif a == 2: -            vec_x[x] += 1 -            vec_x[W] -= 1 -        elif a == 3: -            vec_y[0] += 1 -            vec_y[y] -= 1 -        else: -            vec_y[y] += 1 -            vec_y[H] -= 1 -    vec_x = list(accumulate(vec_x)) -    vec_y = list(accumulate(vec_y)) -    ans = 0 -    for i in range(W): -        for j in range(H): -            if vec_x[i] == 0 and vec_y[j] == 0: -                ans += 1 -    print(ans) +        if a == 1 and x_left < x: +            x_left = x +        elif a == 2 and x_right > x: +            x_right = x +        elif a == 3 and y_left < y: +            y_left = y +        elif a == 4 and y_right > y: +            y_right = y +    print((max(x_right - x_left, 0) * max(y_right - y_left, 0)))