# Baekjoon-20061-모노미노도미노 2

import sys
N = int(input())

blue, green = [[0]*4 for _ in range(6)], [[0]*4 for _ in range(6)]

def check_idx(ys, board):
for idx in range(6):
for y in ys:
if board[idx][y] != 0:
return idx-1
return 5

score = 0
for _ in range(N):
t,x,y = map(int,input().split())
# move block
if t==1:
blue_idx, green_idx = check_idx([x],blue), check_idx([y],green)
blue[blue_idx][x] = 1
green[green_idx][y] = 1
elif t==2:
blue_idx, green_idx = check_idx([x],blue), check_idx([y,y+1],green)
blue[blue_idx-1][x] = 1
blue[blue_idx][x] = 1
green[green_idx][y] = 1
green[green_idx][y+1] = 1
elif t==3:
blue_idx, green_idx = check_idx([x,x+1],blue), check_idx([y],green)
blue[blue_idx][x] = 1
blue[blue_idx][x+1] = 1
green[green_idx-1][y] = 1
green[green_idx][y] = 1

# check line
if t==1:
if blue[blue_idx]==[1,1,1,1]:
blue.pop(blue_idx)
blue.insert(0, [0]*4)
score += 1
if green[green_idx]==[1,1,1,1]:
green.pop(green_idx)
green.insert(0, [0]*4)
score += 1
elif t==2:
if blue[blue_idx-1]==[1,1,1,1]:
blue.pop(blue_idx-1)
blue.insert(0, [0]*4)
score += 1
if blue[blue_idx]==[1,1,1,1]:
blue.pop(blue_idx)
blue.insert(0, [0]*4)
score += 1
if green[green_idx]==[1,1,1,1]:
green.pop(green_idx)
green.insert(0, [0]*4)
score += 1
elif t==3:
if blue[blue_idx]==[1,1,1,1]:
blue.pop(blue_idx)
blue.insert(0, [0]*4)
score += 1
if green[green_idx-1]==[1,1,1,1]:
green.pop(green_idx-1)
green.insert(0, [0]*4)
score += 1
if green[green_idx]==[1,1,1,1]:
green.pop(green_idx)
green.insert(0, [0]*4)
score += 1

# check area
while sum(blue[0]+blue[1]) != 0:
blue.pop()
blue.insert(0, [0]*4)
while sum(green[0]+green[1]) != 0:
green.pop()
green.insert(0, [0]*4)

# print('--b---')
# print(*blue,sep='\n')
# print('--g---')
# print(*green,sep='\n')

result = 0
for i in range(2,6):
result += sum(blue[i])+sum(green[i])
print(score)
print(result)