#include <bits/stdc++.h>
using namespace std;
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
int N;
int a[2010][2010], b[2010][2010];
bool used[2010][2010];
int sz, x[4000010], y[4000010];
int cir, sq;
void issquare(void) {
  int i;
  int xmax = -(1 << 29), xmin = (1 << 29), ymax = -(1 << 29), ymin = (1 << 29);
  if (sz < 50) return;
  for ((i) = 0; (i) < (int)(sz); (i)++) {
    xmax = max(xmax, x[i]);
    xmin = min(xmin, x[i]);
    ymax = max(ymax, y[i]);
    ymin = min(ymin, y[i]);
  }
  double cx = (xmax + xmin) / 2.0, cy = (ymax + ymin) / 2.0;
  double dmax = 0.0;
  for ((i) = 0; (i) < (int)(sz); (i)++) {
    double dx = cx - x[i], dy = cy - y[i];
    dmax = max(dmax, dx * dx + dy * dy);
  }
  double coef = sz / dmax;
  if (coef < 2.5)
    sq++;
  else
    cir++;
}
void dfs(int x2, int y2) {
  if (!(x2 >= 0 && x2 < N && y2 >= 0 && y2 < N) || a[x2][y2] == 0 ||
      used[x2][y2])
    return;
  used[x2][y2] = true;
  x[sz] = x2;
  y[sz] = y2;
  sz++;
  int i;
  for ((i) = 0; (i) < (int)(4); (i)++) dfs(x2 + dx[i], y2 + dy[i]);
}
int main(void) {
  int i, j, k, l;
  scanf("%d", &N);
  for ((i) = 0; (i) < (int)(N); (i)++)
    for ((j) = 0; (j) < (int)(N); (j)++) scanf("%d", &a[i][j]);
  for ((i) = 0; (i) < (int)(N); (i)++)
    for ((j) = 0; (j) < (int)(N); (j)++) {
      int cnt = 0;
      for (k = i - 2; k <= i + 2; k++)
        for (l = j - 2; l <= j + 2; l++)
          if (k >= 0 && k < N && l >= 0 && l < N) cnt += a[k][l];
      if (cnt >= 13) b[i][j] = 1;
    }
  for ((i) = 0; (i) < (int)(N); (i)++)
    for ((j) = 0; (j) < (int)(N); (j)++) a[i][j] = b[i][j];
  for ((i) = 0; (i) < (int)(N); (i)++)
    for ((j) = 0; (j) < (int)(N); (j)++)
      if (a[i][j] == 1 && !used[i][j]) {
        sz = 0;
        dfs(i, j);
        issquare();
      }
  cout << cir << ' ' << sq << endl;
  return 0;
}
