import copy, math
m, n, h = map(int, input().split())
m += 2
n += 2
map = [[] for a in range(m)]
map[0] = ["0" for a in range(n)]
map[m-1] = ["0" for a in range(n)]
pos = [1, 0, -1, 0]
pos2 = [0, 1, 0, -1]
symbol = ["@", "*"]
answer = -math.inf
for a in range(1, m-1):
list = ["0"] + ["_" for a in range(n-2)] + ["0"]
map[a] = list
for a in range(h):
move = [int(a) for a in input().split()]
cor1 = move[0] + 1
cor2 = move[1] + 1
total = 0
inmap = copy.deepcopy(map)
data = []
for i in range(4):
add = 0
cpos = copy.deepcopy(pos)
cpos2 = copy.deepcopy(pos2)
id = i
while True:
if map[cor1 + cpos[i]][cor2 + cpos2[i]] == "_" :
break
if map[cor1 + cpos[i]][cor2 + cpos2[i]] == "@" :
data.append([add, cor1 + cpos[i], cor2 + cpos2[i], id])
break
elif map[cor1 + cpos[i]][cor2 + cpos2[i]] == '0':
break
if pos[i] == 1 :
cpos[i] += 1
elif pos[i] == -1:
cpos[i] -= 1
elif pos2[i] == 1:
cpos2[i] += 1
else:
cpos2[i] -= 1
add += 1
for z in data:
for s in range(z[0]):
status = 0
for i in range(4):
if map[z[1] - pos[z[3]]*(s + 1) + pos[i]][z[2] - pos2[z[3]]*(s + 1) + pos2[i]] == "@" or map[z[1] - pos[z[3]]*(s + 1) + pos[i]][z[2] - pos2[z[3]]*(s + 1) + pos2[i]] == "*":
status += 1
if status != 4:
inmap[z[1] - pos[z[3]]*(s + 1)][z[2] - pos2[z[3]]*(s + 1)] = "_"
if move[2] == 1:
inmap[cor1][cor2] = "_"
if move[2] == 0:
inmap[cor1][cor2] = "@"
data = []
for i in range(4):
add = 0
cpos = copy.deepcopy(pos)
cpos2 = copy.deepcopy(pos2)
id = i
while True:
if map[cor1 + cpos[i]][cor2 + cpos2[i]] == "@" :
data.append([add, cor1 + cpos[i], cor2 + cpos2[i], id])
break
elif map[cor1 + cpos[i]][cor2 + cpos2[i]] == '0':
break
if pos[i] == 1 :
cpos[i] += 1
elif pos[i] == -1:
cpos[i] -= 1
elif pos2[i] == 1:
cpos2[i] += 1
else:
cpos2[i] -= 1
add += 1
for z in data:
for s in range(z[0]):
inmap[z[1] - pos[z[3]]*(s + 1)][z[2] - pos2[z[3]]*(s + 1)] = "*"
map = inmap
for a in map:
for i in a:
if i == "@" or i == "*":
total += 1
if total > answer:
answer = total
print(answer)
answer = 0
for a in map:
for i in a:
if i == "@" or i == "*":
answer += 1
print(answer)