#include <iostream>
#include <cstdio>
#include <cstring>

using namespace std;

const int maxN=2010;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const double pi=3.1415926535897932384626433832795028841971693993751;

struct point
{
    int x,y;
};

int n;
int a[maxN][maxN];
int tot,sq,ci;
point queue[maxN*maxN];
int hd,tl;
bool color[maxN][maxN];


double abs(double x)
{
    if (x>0)
        return x;
    else
        return -x;
}

void fill(int xx,int yy)
{
    tot++;
    hd=1;
    tl=2;
    queue[1].x=xx;
    queue[1].y=yy;
    color[xx][yy]=tot;
    int Count=1;
    int l=xx,r=xx,u=yy,d=yy;
    while (hd<tl)
    {
        int nextx=queue[hd].x;
        int nexty=queue[hd].y;
        hd++;
        for (int i=0;i<4;i++)
            if (color[nextx+dx[i]][nexty+dy[i]]==0)
            {
                color[nextx+dx[i]][nexty+dy[i]]=tot;
                Count++;
                queue[tl].x=nextx+dx[i];
                queue[tl].y=nexty+dy[i];
                if (l>nextx+dx[i])
                    l=nextx+dx[i];
                if (r<nextx+dx[i])
                    r=nextx+dx[i];
                if (d>nexty+dy[i])
                    d=nexty+dy[i];
                if (u<nexty+dy[i])
                    u=nexty+dy[i];
                tl++;
            }
    }
    int R=(r+u-l-d)/4;
    double S=R*R*pi;
    if (abs(Count-S)<R)
        ci++;
    else 
        sq++;
}

int main()
{
//    freopen("cf178e.in","r",stdin);
    scanf("%d\n",&n);
    memset(color,0,sizeof(color));
    for (int i=1;i<=n;i++)
    {
        for (int j=1;j<=n;j++)
        {
            scanf("%d",&a[i][j]);
            if (a[i][j]==0)
                color[i][j]=1;
        }
        scanf("\n");
    }
    for (int i=0;i<=n+1;i++)
    {
        color[0][i]=1;
        color[i][0]=1;
        color[n+1][i]=1;
        color[i][n+1]=1;
    }
    tot=1;
    sq=0;
    ci=0;
    for (int i=1;i<=n;i++)
        for (int j=1;j<=n;j++)
        {
            if (color[i][j]==0)
                fill(i,j);
        }
    printf("%d %d\n",ci,sq);
    return 0;
}
