def resolve():

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

	r = [[True]*w for _ in range(h)]

	for _ in range(n):

		ix, iy, a = list(map(int, input().split()))

		if a == 1:

			for i in range(h):

				for j in range(ix):

					r[i][j] = False

		elif a == 2:

			for i in range(h):

				for j in range(ix, w):

					r[i][j] = False

		elif a == 3:

			for i in range(iy):

				for j in range(w):

					r[i][j] = False

		else:

			for i in range(iy, h):

				for j in range(w):

					r[i][j] = False

	ans = 0



	for row in r:

		for i in row:

			if i:

				ans += 1

	print(ans)

resolve()
def resolve():

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

	r = [[True]*w for _ in range(h)]

	for i in range(n):

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

		if a == 1:

			for j in range(h):

				for k in range(x):

					r[j][k] = False

		if a == 2:

			for j in range(h):

				for k in range(x, w):

					r[j][k] = False

		if a == 3:

			for j in range(y):

				for k in range(w):

					r[j][k] = False

		if a == 4:

			for j in range(y, h):

				for k in range(w):

					r[j][k] = False

	ans = 0

	for i in range(h):

		for j in r[i]:

			if j:

				ans += 1

	print(ans)

resolve()
def resolve():
    w, h, n = list(map(int, input().split()))
    r = [[True] * w for _ in range(h)]
    for _ in range(n):
        ix, iy, a = list(map(int, input().split()))
        if a == 1:
            for i in range(h):
                for j in range(ix):
                    r[i][j] = False
        elif a == 2:
            for i in range(h):
                for j in range(ix, w):
                    r[i][j] = False
        elif a == 3:
            for i in range(iy):
                for j in range(w):
                    r[i][j] = False
        else:
            for i in range(iy, h):
                for j in range(w):
                    r[i][j] = False
    ans = 0
    for row in r:
        for i in row:
            if i:
                ans += 1
    print(ans)


resolve()

def resolve():
    w, h, n = list(map(int, input().split()))
    r = [[True] * w for _ in range(h)]
    for i in range(n):
        x, y, a = list(map(int, input().split()))
        if a == 1:
            for j in range(h):
                for k in range(x):
                    r[j][k] = False
        if a == 2:
            for j in range(h):
                for k in range(x, w):
                    r[j][k] = False
        if a == 3:
            for j in range(y):
                for k in range(w):
                    r[j][k] = False
        if a == 4:
            for j in range(y, h):
                for k in range(w):
                    r[j][k] = False
    ans = 0
    for i in range(h):
        for j in r[i]:
            if j:
                ans += 1
    print(ans)


resolve()

-    for _ in range(n): -        ix, iy, a = list(map(int, input().split())) +    for i in range(n): +        x, y, a = list(map(int, input().split())) -            for i in range(h): -                for j in range(ix): -                    r[i][j] = False -        elif a == 2: -            for i in range(h): -                for j in range(ix, w): -                    r[i][j] = False -        elif a == 3: -            for i in range(iy): -                for j in range(w): -                    r[i][j] = False -        else: -            for i in range(iy, h): -                for j in range(w): -                    r[i][j] = False +            for j in range(h): +                for k in range(x): +                    r[j][k] = False +        if a == 2: +            for j in range(h): +                for k in range(x, w): +                    r[j][k] = False +        if a == 3: +            for j in range(y): +                for k in range(w): +                    r[j][k] = False +        if a == 4: +            for j in range(y, h): +                for k in range(w): +                    r[j][k] = False -    for row in r: -        for i in row: -            if i: +    for i in range(h): +        for j in r[i]: +            if j: