import sys
input = sys.stdin.readline
def chk(x, y, n, count):
color = paper[x][y]
for i in range(x, x+n):
for j in range(y, y+n):
if paper[i][j] != color:
m = n // 2
chk(x, y, m, count)
chk(x, y + m, m, count)
chk(x + m, y, m, count)
chk(x + m, y + m, m, count)
return
count[color] += 1
n = int(input())
paper = [list(map(int, input().split())) for _ in range(n)]
count = [0, 0]
chk(0, 0, n, count)
print(count[0])
print(count[1])
PREVIOUS[백준] 색종이 만들기