#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:100000000")
using namespace std;
int a[2010][2010];
int u[2010][2010];
int n, ima, imi, jma, jmi;
struct T {
  int i, j;
} v[4000010];
int lv;
void dfs(int i, int j) {
  u[i][j] = 1;
  if (i > ima) ima = i;
  if (i < imi) imi = i;
  if (j > jma) jma = j;
  if (j < jmi) jmi = j;
  int l, ii, jj, b = 0;
  for (l = 0; l < 9; l++) {
    ii = i + (l / 3 - 1);
    jj = j + (l % 3 - 1);
    if (ii >= 0 && jj >= 0 && ii < n && jj < n && a[ii][jj]) {
      if (!u[ii][jj]) dfs(ii, jj);
    } else
      b = 1;
  }
  if (b) {
    v[lv].i = i;
    v[lv].j = j;
    lv++;
  }
}
int main() {
  int i, j, k, cir = 0, rect = 0;
  double iav, jav, dmin, dmax, d;
  scanf("%d", &n);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (!u[i][j] && a[i][j]) {
        lv = 0;
        ima = jma = -1999999999;
        imi = jmi = 1999999999;
        dfs(i, j);
        iav = (ima + imi) / 2.0;
        jav = (jma + jmi) / 2.0;
        dmin = 1E20;
        dmax = -1E20;
        for (k = 0; k < lv; k++) {
          d = sqrt((v[k].i - iav) * (v[k].i - iav) +
                   (v[k].j - jav) * (v[k].j - jav));
          if (d < dmin) dmin = d;
          if (d > dmax) dmax = d;
        }
        if (dmax - dmin > 3)
          rect++;
        else
          cir++;
      }
  printf("%d %d\n", cir, rect);
  return 0;
}
