#include <bits/stdc++.h>
using namespace std;
long N;
long Grid[2007 + 7][2007 + 7];
bool IsB[2007 + 7][2007 + 7];
bool Visit[2007 + 7][2007 + 7];
long Sz;
long R[8 * 2007 + 7], C[8 * 2007 + 7];
long Tot;
long IR[] = {0, -1, 0, 1};
long IC[] = {1, 0, -1, 0};
void FloodFill(long r, long c) {
  if (!Grid[r][c]) return;
  if (Visit[r][c]) return;
  Visit[r][c] = true;
  if (IsB[r][c]) {
    Sz++;
    R[Sz] = r;
    C[Sz] = c;
  }
  Tot++;
  long k;
  for (k = 0; k < 4; k++) {
    FloodFill(r + IR[k], c + IC[k]);
  }
}
long FindD2(void) {
  long i, j, D = 0;
  for (i = 1; i <= Sz; i++) {
    for (j = i + 1; j <= Sz; j++) {
      long Dx = R[i] - R[j];
      long Dy = C[i] - C[j];
      D = max(D, Dx * Dx + Dy * Dy);
    }
  }
  return D;
}
int main(void) {
  long i, j, k;
  char Ch;
  double PI = 2 * acos(0.0);
  cin >> N;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      scanf("%ld", &Grid[i][j]);
    }
  }
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      for (k = 0; k < 4; k++) {
        long nr = i + IR[k];
        long nc = j + IC[k];
        if (Grid[nr][nc]) {
          IsB[i][j] = true;
          break;
        }
      }
    }
  }
  long Sq = 0, Cr = 0;
  for (i = 1; i <= N; i++) {
    for (j = 1; j <= N; j++) {
      if (!Grid[i][j] || Visit[i][j]) continue;
      Tot = 0;
      Sz = 0;
      FloodFill(i, j);
      long D2 = FindD2();
      double SqA = D2 / 2.0;
      double CrA = (PI * D2) / 4.0;
      if (fabs(Tot - SqA) < fabs(Tot - CrA))
        Sq++;
      else
        Cr++;
    }
  }
  printf("%ld %ld\n", Cr, Sq);
  return 0;
}
