#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:500000000")
using namespace std;
int A[2002][2002];
bool used[2002][2002];
int _i[] = {0, 0, 1, -1};
int _j[] = {1, -1, 0, 0};
int n, m;
void dfs(int i, int j) {
  used[i][j] = 1;
  for (int k = 0; k < 4; k++) {
    if (i + _i[k] < n && j + _j[k] < m && !used[i + _i[k]][j + _j[k]] &&
        A[i + _i[k]][j + _j[k]]) {
      dfs(i + _i[k], j + _j[k]);
    }
  }
}
int main() {
  int i, j;
  scanf("%d", &n);
  m = n;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++) scanf("%d", &A[i][j]);
  int rect = 0;
  for (i = 4; i <= n; i++) {
    for (j = 4; j <= m; j++) {
      int sum = 0;
      for (int k = i - 3; k <= i; k++) {
        for (int h = j - 3; h <= j; h++) {
          sum += A[k][h];
        }
      }
      if (sum == 16 && (!A[i][j - 4] && !A[i - 4][j])) rect++;
    }
  }
  int cnt = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= m; j++)
      if (!used[i][j] && A[i][j]) dfs(i, j), cnt++;
  printf("%d %d\n", cnt - rect, rect);
}
