#include <bits/stdc++.h>
const int N = 2010;
const double pi = acos(-1);
int sum, lx, ly, f[N][N];
bool vis[N][N];
void work(int x, int y) {
  if (!f[x][y] || vis[x][y]) return;
  sum++;
  vis[x][y] = true;
  if (x > lx || (x == lx && y > ly)) {
    lx = x;
    ly = y;
  }
  work(x - 1, y);
  work(x, y - 1);
  work(x + 1, y);
  work(x, y + 1);
}
int main() {
  int n, i, j, k, l, s, ans1 = 0, ans2 = 0;
  double d, delta1, delta2;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) scanf("%d", &f[i][j]);
  for (i = 0; i <= n + 1; i++)
    f[0][i] = f[n + 1][i] = f[i][0] = f[i][n + 1] = 0;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) {
      if (f[i][j] && !f[i - 1][j] && !f[i][j - 1] && !f[i + 1][j] &&
          !f[i][j + 1])
        f[i][j] = 0;
      if (!f[i][j] && f[i - 1][j] && f[i][j - 1] && f[i + 1][j] && f[i][j + 1])
        f[i][j] = 1;
    }
  memset(vis, false, sizeof(vis));
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (f[i][j] && !vis[i][j]) {
        lx = i;
        ly = j;
        sum = 0;
        work(i, j);
        d = sqrt((lx - i) * (lx - i) + (ly - j) * (ly - j));
        if (d > 14) {
          delta1 = fabs(d * d * 0.25 * pi - sum);
          delta2 = fabs(d * d * 0.5 - sum);
          if (delta1 < delta2)
            ans1++;
          else
            ans2++;
        }
      }
  printf("%d %d", ans1, ans2);
}
