#include <bits/stdc++.h>
using namespace std;
int a[2005][2005];
int u[2005][2005];
int n;
int xa, ya, xb, yb, xc, yc, xd, yd, cnt = 0;
bool valid(int x, int y) {
  return x >= 0 && x < n && y >= 0 && y < n && a[x][y] == 1 && !u[x][y];
}
void go(int x, int y) {
  if (x < xa || (x == xa && ya < y)) {
    xa = x;
    ya = y;
  }
  if (x > xb || (x == xb && yb > y)) {
    xb = x;
    yb = y;
  }
  if (x < xc || (x == xc && yc > y)) {
    xc = x;
    yc = y;
  }
  if (x > xd || (x == xd && yd < y)) {
    xd = x;
    yd = y;
  }
  u[x][y] = 1;
  ++cnt;
  for (int i = -1; i <= 1; i++)
    for (int j = -1; j <= 1; j++)
      if (valid(x + i, y + j)) go(x + i, y + j);
}
int main(void) {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  int square = 0, circle = 0;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] && !u[i][j]) {
        xa = n, ya = n, xb = -1, yb = -1;
        cnt = 0;
        xc = yc = n, xd = yd = -1;
        go(i, j);
        double cx = (xa + xb) / 2., cy = (ya + yb) / 2.;
        double est = (xa - xb) * (xa - xb) + (ya - yb) * (ya - yb);
        double est2 = (xc - xd) * (xc - xd) + (yc - yd) * (yc - yd);
        est = (est + est2) / 4.;
        if (cnt <= est * 1.5) {
          square++;
        } else
          circle++;
      }
  printf("%d %d\n", circle, square);
  return 0;
}
