m,n,h=map(int,input().split())
temp=[]
Map=[[0]*n for i in range(m)]
biggest=0
for k in range(h):
inf=list(map(int,input().split()))
temp.append(inf)
now=inf[2]
y=inf[0]
x=inf[1]
if now==0:
Map[inf[0]][inf[1]]="@"
#right
for j in range(inf[1]+1,n):
t=True
if Map[inf[0]][j]=="@":
for i in range(inf[1]+1,j):
if Map[inf[0]][i]=="|":
Map[inf[0]][i]="+"
else:
Map[inf[0]][i]="-"
t=False
break
if t==False:
break
#left
for j in range(inf[1]-1,-1,-1):
t=True
if Map[inf[0]][j]=="@":
for i in range(inf[1]-1,j,-1):
if Map[inf[0]][i]=="|":
Map[inf[0]][i]="+"
else:
Map[inf[0]][i]="-"
t=False
break
if t==False:
break
#down
for j in range(inf[0]+1,m):
t=True
if Map[j][inf[1]]=="@":
for i in range(inf[0]+1,j):
if Map[i][inf[1]]=="-":
Map[i][inf[1]]="+"
else:
Map[i][inf[1]]="|"
t=False
break
if t==False:
break
#up
for j in range(inf[0]-1,-1,-1):
t=True
if Map[j][inf[1]]=="@":
for i in range(inf[0]-1,j,-1):
if Map[i][inf[1]]=="-":
Map[i][inf[1]]="+"
else:
Map[i][inf[1]]="|"
t=False
break
if t==False:
break
else:
Map[inf[0]][inf[1]]=0
#right
for j in range(inf[1]+1,n):
t=True
if Map[inf[0]][j]=="@":
for i in range(inf[1]+1,j):
if Map[inf[0]][i]=="+":
Map[inf[0]][i]="|"
else:
Map[inf[0]][i]=0
t=False
break
if t==False:
break
#left
for j in range(inf[1]-1,-1,-1):
t=True
if Map[inf[0]][j]=="@":
for i in range(inf[1]-1,j,-1):
if Map[inf[0]][i]=="+":
Map[inf[0]][i]="|"
else:
Map[inf[0]][i]=0
t=False
break
if t==False:
break
#down
for j in range(inf[0]+1,m):
t=True
if Map[j][inf[1]]=="@":
for i in range(inf[0]+1,j):
if Map[i][inf[1]]=="+":
Map[i][inf[1]]="-"
else:
Map[i][inf[1]]=0
t=False
break
if t==False:
break
#up
for j in range(inf[0]-1,-1,-1):
t=True
if Map[j][inf[1]]=="@":
for i in range(inf[0]-1,j,-1):
if Map[i][inf[1]]=="+":
Map[i][inf[1]]="-"
else:
Map[i][inf[1]]=0
t=False
break
if t==False:
break
Final=0
for i in range(m):
for j in range(n):
if Map[i][j]!=0:
Final+=1
if Final>biggest:
biggest=Final
#print(Map)
print(biggest)
print(Final)