def cin():
	return map(int,input().split())

def cino(test=False):
    if not test:
        return int(input())
    else:
        return input()
def cina():
  return list(map(int,input().split()))


a,b,c  = cin()
p = -1
q = 1e9
r = -1
s = 1e9
for i in range(c):
  x,y,z = cin()
  if z==1:
    p = max(x,p)
  elif z==2:
    q = min(x,q)
  elif z==3:
    r = max(r,y)
  else:
    s = min(s,y)

if p==-1:
    p = 0
if q==1e9:
    q = a
if r==-1:
    r=0
if s==1e9:
    s=b

# v = a-(a-p-1+a-q)
# w = b-(b-r+b-s)
# print(v,w)
ans = (q-p)*(s-r)
if ans>0:
    print(ans)
else:
    print(0)
# print(ans if ans>0 else 0)

# l1 = list(range(0,p+1))
# l2 = list(range(q,a))
# l1 = set(l1)
# l2 = set(l2)
# l3 = l1.union(l2)

# l4 = list(range(0,r))
# l5 = list(range(s,b+1))
# l4 = set(l4)
# l5 = set(l5)
# l6 = l4.union(l5)
# # print(l3,l6)
# # print(l1,l2)
# # print(p,q,r,s)
# if(len(l3)==a or len(l6)==b):
#     print(0)
# else:
#     print((a-len(l3)+1)*(b-len(l6)+1))
    
    
  
