def main():

  w, h, n = input_list()

  

  points = []

  for x in range(w):

    row = [True]*h

    points.append(row)

      

  for _ in range(n):

    x, y, a = input_list()

    if a == 1:

      for px, row in enumerate(points):

        for py, v in enumerate(row):

          if px+1 <= x:

            points[px][py] = False

    if a == 2:

      for px, row in enumerate(points):

        for py, v in enumerate(row):

          if px+1 > x:

            points[px][py] = False

    if a == 3:

      for px, row in enumerate(points):

        for py, v in enumerate(row):

          if py+1 <= y:

            points[px][py] = False

    if a == 4:

      for px, row in enumerate(points):

        for py, v in enumerate(row):

          if py+1 > y:

            points[px][py] = False

  ans = 0

  for p in points:

    ans += p.count(True)

  print(ans)



def input_list():

  return list(map(int, input().split()))



import math

main()
# import sys

# input = sys.stdin.readline

import itertools





# 持っているビスケットを叩き、1枚増やす

# ビスケット A枚を 1円に交換する

# 1円をビスケット B枚に交換する

def main():

    w, h, n = input_list()

    zahyou = [[0]*w for _ in range(h)]

    for _ in range(n):

        x, y, a = input_list()

        umeru(zahyou, x, y, a)

    ans = 0

    for hz in zahyou:

        ans += hz.count(0)

    print(ans)



def umeru(zu, x, y, a):

    for Y, row in enumerate(zu):

        for X, v in enumerate(row):

            if a == 1:

                if X < x:

                    zu[Y][X] = 1

            if a == 2:

                if X > x - 1:

                    zu[Y][X] = 1

            if a == 3:

                if Y < y:

                    zu[Y][X] = 1

            if a == 4:

                if Y > y - 1:

                    zu[Y][X] = 1





def input_list():

    return list(map(int, input().split()))





def input_list_str():

    return list(map(str, input().split()))





if __name__ == "__main__":

    main()

def main():
    w, h, n = input_list()
    points = []
    for x in range(w):
        row = [True] * h
        points.append(row)
    for _ in range(n):
        x, y, a = input_list()
        if a == 1:
            for px, row in enumerate(points):
                for py, v in enumerate(row):
                    if px + 1 <= x:
                        points[px][py] = False
        if a == 2:
            for px, row in enumerate(points):
                for py, v in enumerate(row):
                    if px + 1 > x:
                        points[px][py] = False
        if a == 3:
            for px, row in enumerate(points):
                for py, v in enumerate(row):
                    if py + 1 <= y:
                        points[px][py] = False
        if a == 4:
            for px, row in enumerate(points):
                for py, v in enumerate(row):
                    if py + 1 > y:
                        points[px][py] = False
    ans = 0
    for p in points:
        ans += p.count(True)
    print(ans)


def input_list():
    return list(map(int, input().split()))


import math

main()

# import sys
# input = sys.stdin.readline
import itertools

# 持っているビスケットを叩き、1枚増やす
# ビスケット A枚を 1円に交換する
# 1円をビスケット B枚に交換する
def main():
    w, h, n = input_list()
    zahyou = [[0] * w for _ in range(h)]
    for _ in range(n):
        x, y, a = input_list()
        umeru(zahyou, x, y, a)
    ans = 0
    for hz in zahyou:
        ans += hz.count(0)
    print(ans)


def umeru(zu, x, y, a):
    for Y, row in enumerate(zu):
        for X, v in enumerate(row):
            if a == 1:
                if X < x:
                    zu[Y][X] = 1
            if a == 2:
                if X > x - 1:
                    zu[Y][X] = 1
            if a == 3:
                if Y < y:
                    zu[Y][X] = 1
            if a == 4:
                if Y > y - 1:
                    zu[Y][X] = 1


def input_list():
    return list(map(int, input().split()))


def input_list_str():
    return list(map(str, input().split()))


if __name__ == "__main__":
    main()

+# import sys +# input = sys.stdin.readline +import itertools + +# 持っているビスケットを叩き、1枚増やす +# ビスケット A枚を 1円に交換する +# 1円をビスケット B枚に交換する -    points = [] -    for x in range(w): -        row = [True] * h -        points.append(row) +    zahyou = [[0] * w for _ in range(h)] -        if a == 1: -            for px, row in enumerate(points): -                for py, v in enumerate(row): -                    if px + 1 <= x: -                        points[px][py] = False -        if a == 2: -            for px, row in enumerate(points): -                for py, v in enumerate(row): -                    if px + 1 > x: -                        points[px][py] = False -        if a == 3: -            for px, row in enumerate(points): -                for py, v in enumerate(row): -                    if py + 1 <= y: -                        points[px][py] = False -        if a == 4: -            for px, row in enumerate(points): -                for py, v in enumerate(row): -                    if py + 1 > y: -                        points[px][py] = False +        umeru(zahyou, x, y, a) -    for p in points: -        ans += p.count(True) +    for hz in zahyou: +        ans += hz.count(0) + + +def umeru(zu, x, y, a): +    for Y, row in enumerate(zu): +        for X, v in enumerate(row): +            if a == 1: +                if X < x: +                    zu[Y][X] = 1 +            if a == 2: +                if X > x - 1: +                    zu[Y][X] = 1 +            if a == 3: +                if Y < y: +                    zu[Y][X] = 1 +            if a == 4: +                if Y > y - 1: +                    zu[Y][X] = 1 -import math +def input_list_str(): +    return list(map(str, input().split())) -main() + +if __name__ == "__main__": +    main()