#include <bits/stdc++.h>
using namespace std;
char image[2000][2000];
int mini, maxi, minj, maxj, filled, n;
void fill(int i, int j) {
  image[i][j] = 2;
  ++filled;
  mini = min(i, mini);
  minj = min(j, minj);
  maxi = max(i, maxi);
  maxj = max(j, maxj);
  if (i > 0 && image[i - 1][j] == 1) fill(i - 1, j);
  if (j > 0 && image[i][j - 1] == 1) fill(i, j - 1);
  if (i < n - 1 && image[i + 1][j] == 1) fill(i + 1, j);
  if (j < n - 1 && image[i][j + 1] == 1) fill(i, j + 1);
}
bool is_circle() {
  int bad = 0;
  int ci = (mini + maxi) / 2;
  int cj = (minj + maxj) / 2;
  int rsq = ((maxi - mini) * (maxj - minj) + 2) / 4;
  for (int i = mini; i <= maxi; ++i) {
    for (int j = minj; j <= maxj; ++j) {
      int distsq = (ci - i) * (ci - i) + (cj - j) * (cj - j);
      if (distsq > rsq + 2 && image[i][j] == 2) ++bad;
      if (distsq < rsq - 2 && image[i][j] == 0) ++bad;
    }
  }
  return bad * 4.5 < (maxi - mini + 1) * (maxj - minj + 1);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      scanf("%hhd", &image[i][j]);
    }
  }
  int circles = 0, squares = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (image[i][j] == 1) {
        mini = minj = n;
        maxi = maxj = 0;
        filled = 0;
        fill(i, j);
        if (maxj - minj + maxi - mini < 25) continue;
        if (is_circle())
          ++circles;
        else
          ++squares;
      }
    }
  }
  printf("%d %d\n", circles, squares);
  return 0;
}
