#include <iostream>
#include <algorithm>
#include <numeric>
using namespace std;
struct Paper{
int minusOne;
int zero;
int plusOne;
};
int buffer[2200][2200];
Paper cut(int startx, int starty, int length){
if (length == 1){
if (buffer[startx][starty]==1){
Paper paper;
paper.minusOne = 0;
paper.plusOne = 0;
paper.zero = 1;
return paper;
}else if (buffer[startx][starty] == 0){
Paper paper;
paper.minusOne = 1;
paper.plusOne = 0;
paper.zero = 0;
return paper;
}else {
Paper paper;
paper.minusOne = 0;
paper.plusOne = 1;
paper.zero = 0;
return paper;
}
}
Paper paper;
paper.minusOne = 0;
paper.zero = 0;
paper.plusOne = 0;
for (int i = 0; i<3; i++){
for(int j = 0; j<3;j++){
// paper.zero += (papers[i][j]).zero;
// paper.minusOne += (papers[i][j]).minusOne;
// paper.plusOne += (papers[i][j]).plusOne;
int newStartX = startx + ((length/3)*i);
int newStartY = starty + ((length/3)*j);
Paper temp = cut(newStartX, newStartY , length/3);
paper.zero += temp.zero;
paper.plusOne += temp.plusOne;
paper.minusOne += temp.minusOne;
}
}
if (paper.minusOne == 0 && paper.zero == 0){
paper.plusOne = 1;
}
if (paper.plusOne == 0 && paper.zero == 0){
paper.minusOne = 1;
}
if (paper.minusOne == 0 && paper.plusOne== 0){
paper.zero = 1;
}
return paper;
}
int main() {
ios::sync_with_stdio(false);
cin.tie(NULL);
int n;
cin >> n;
for (int i = 0; i<n; i++){
for (int j=0; j<n; j++){
int temp ;
cin >> temp;
buffer[i][j] = temp+1;
}
}
Paper paper = cut(0,0,n);
cout << paper.minusOne << '\n';
cout << paper.zero << '\n';
cout << paper.plusOne << '\n';
return 0;
}