W,H,N = map(int,input().split())
li = []

for i in range(N):
  li.append(list(map(int,input().split())))

s = [[0, W], [0, H]]

for x in li:
  if x[2] == 1:
    if s[0][0] < x[0]:
      s[0][0] = x[0]
  
  if x[2] == 2:
    if s[0][1] > x[0]:
      s[0][1] = x[0]
  
  if x[2] == 3:
    if s[1][0] < x[1]:
      s[1][0] = x[1]
  
  if x[2] == 4:
    if s[1][1] > x[1]:
      s[1][1] = x[1]
      
if s[0][1] - s[0][0] < 0 or s[1][1] - s[1][0]:
  print(0)
else:
  print(s[0][1] - s[0][0] * s[1][1] - s[1][0])