#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define ss stable_sort
#define ll long long
int paper[128][128];
int white , blue;
void Devide(int x, int y, int s) { //분할 함수
int color = paper[x][y]; //왼쪽 모서리 색깔저장
for (int i = x; i < x + s; i++) {
for (int j = y; j < y + s; j++) { //사이즈내를 돌면서
if (color == 0 && paper[i][j]==1) {
color = 2;
}
else if (color == 1 && paper[i][j] == 0) { //색깔이 다르면
color = 2; //color를 2로 설정
}
if (color == 2) {
Devide(x, y, s / 2);
Devide(x, y+s/2, s / 2);
Devide(x+s/2, y, s / 2);
Devide(x+s/2, y+s/2, s / 2); //color가 2로 설정돼 있으면
//동일한 크기의 4개로 분할
return;
}
}
}
if (color==1) {
blue++; //색깔이 모두 같으면 해당 색깔++
}
else {
white++;
}
}
int main() {
cin.tie(0)->sync_with_stdio(0);
int n;
cin >> n;
for (int i = 0; i < n; i++) {
for (int j = 0; j < n; j++) {
cin >> paper[i][j];
}
} //입력
Devide(0, 0, n); //0,0에 사이즈는 n
cout << white << "\n" << blue;
return 0;
}