import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2

from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby

from operator import itemgetter, mul

from copy import deepcopy, copy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left

from fractions import gcd

from heapq import heappush, heappop

from functools import reduce

def input(): return sys.stdin.readline().strip()

def INT(): return int(eval(input()))

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

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

def ZIP(n): return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7

import numpy as np



W, H, N = MAP()



w, h = np.zeros(W), np.zeros(H)



for _ in range(N):

	x, y, a = MAP()

	if a == 1:

		w[:x] = 1

	elif a == 2:

		w[x:] = 1

	elif a == 3:

		h[:y] = 1

	elif a == 4:

		h[y:] = 1



print((list(w).count(0) * list(h).count(0)))

import sys, re

from collections import deque, defaultdict, Counter

from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians#, log2

from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby

from operator import itemgetter, mul

from copy import deepcopy, copy

from string import ascii_lowercase, ascii_uppercase, digits

from bisect import bisect, bisect_left, insort, insort_left

from fractions import gcd

from heapq import heappush, heappop

from functools import reduce

def input(): return sys.stdin.readline().strip()

def INT(): return int(eval(input()))

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

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

def ZIP(n): return list(zip(*(MAP() for _ in range(n))))

sys.setrecursionlimit(10 ** 9)

INF = float('inf')

mod = 10 ** 9 + 7

#import numpy as np

#from decimal import *



W, H, N = MAP()

 

dict = defaultdict(int)

dict[1] = 0

dict[2] = W

dict[3] = 0

dict[4] = H

 

for _ in range(N):

	x, y, a = MAP()

	if a == 1:

		dict[1] = max(x, dict[1])

	elif a == 2:

		dict[2] = min(x, dict[2])

	elif a == 3:

		dict[3] = max(y, dict[3])

	elif a == 4:

		dict[4] = min(y, dict[4])

 

if dict[2]-dict[1] < 0 or dict[4]-dict[3] < 0:

	print((0))

else:

	print((max(0, (dict[2]-dict[1])*(dict[4]-dict[3]))))
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import (
    accumulate,
    permutations,
    combinations,
    combinations_with_replacement,
    product,
    groupby,
)
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


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


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


def ZIP(n):
    return list(zip(*(MAP() for _ in range(n))))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
import numpy as np

W, H, N = MAP()
w, h = np.zeros(W), np.zeros(H)
for _ in range(N):
    x, y, a = MAP()
    if a == 1:
        w[:x] = 1
    elif a == 2:
        w[x:] = 1
    elif a == 3:
        h[:y] = 1
    elif a == 4:
        h[y:] = 1
print((list(w).count(0) * list(h).count(0)))

import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians  # , log2
from itertools import (
    accumulate,
    permutations,
    combinations,
    combinations_with_replacement,
    product,
    groupby,
)
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left, insort, insort_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce


def input():
    return sys.stdin.readline().strip()


def INT():
    return int(eval(input()))


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


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


def ZIP(n):
    return list(zip(*(MAP() for _ in range(n))))


sys.setrecursionlimit(10**9)
INF = float("inf")
mod = 10**9 + 7
# import numpy as np
# from decimal import *
W, H, N = MAP()
dict = defaultdict(int)
dict[1] = 0
dict[2] = W
dict[3] = 0
dict[4] = H
for _ in range(N):
    x, y, a = MAP()
    if a == 1:
        dict[1] = max(x, dict[1])
    elif a == 2:
        dict[2] = min(x, dict[2])
    elif a == 3:
        dict[3] = max(y, dict[3])
    elif a == 4:
        dict[4] = min(y, dict[4])
if dict[2] - dict[1] < 0 or dict[4] - dict[3] < 0:
    print((0))
else:
    print((max(0, (dict[2] - dict[1]) * (dict[4] - dict[3]))))

-from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2 +from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians  # , log2 -from bisect import bisect, bisect_left +from bisect import bisect, bisect_left, insort, insort_left -import numpy as np - +# import numpy as np +# from decimal import * -w, h = np.zeros(W), np.zeros(H) +dict = defaultdict(int) +dict[1] = 0 +dict[2] = W +dict[3] = 0 +dict[4] = H -        w[:x] = 1 +        dict[1] = max(x, dict[1]) -        w[x:] = 1 +        dict[2] = min(x, dict[2]) -        h[:y] = 1 +        dict[3] = max(y, dict[3]) -        h[y:] = 1 -print((list(w).count(0) * list(h).count(0))) +        dict[4] = min(y, dict[4]) +if dict[2] - dict[1] < 0 or dict[4] - dict[3] < 0: +    print((0)) +else: +    print((max(0, (dict[2] - dict[1]) * (dict[4] - dict[3]))))