https://www.acmicpc.net/problem/2630
import sys
def divide(y, x, n):
colors=maps[y][x]
for i in range(y, y+n):
for j in range(x, x+n):
if colors != maps[i][j]:
divide(y,x,n//2)
divide(y,x + n//2,n//2)
divide(y + n //2, x, n // 2)
divide(y + n // 2, x + n//2, n // 2)
return
cnt[colors]+=1
maps=[]
n = int(sys.stdin.readline())
for _ in range(n):
maps.append(list(map(int, sys.stdin.readline().strip().split())))
cnt=[0,0]
divide(0,0,n)
for i in cnt:
print(i)