#include <bits/stdc++.h>
const int MAXN = 2000;
bool img[MAXN + 2][MAXN + 2] = {0};
bool was[MAXN + 2][MAXN + 2] = {0};
int pr[MAXN * MAXN][2], head, tail;
void bfs(int i0, int j0) {
  int i, di, j, dj;
  was[i0][j0] = 1;
  head = tail = 0;
  pr[tail][0] = i0;
  pr[tail][1] = j0;
  ++tail;
  while (head < tail) {
    i0 = pr[head][0];
    j0 = pr[head][1];
    ++head;
    for (di = -1; di <= 1; ++di)
      for (dj = -1; dj <= 1; ++dj) {
        i = i0 + di;
        j = j0 + dj;
        if (!was[i][j] && img[i][j]) {
          was[i][j] = 1;
          pr[tail][0] = i;
          pr[tail][1] = j;
          ++tail;
        }
      }
  }
}
int main() {
  int n, i, j, pix, sq = 0, cir = 0;
  scanf("%d", &n);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) {
      scanf("%d", &pix);
      img[i][j] = pix;
    }
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j)
      if (!was[i][j] && img[i][j]) {
        img[i + 1][j - 1] ? ++cir : ++sq;
        bfs(i, j);
      }
  printf("%d %d\n", cir, sq);
  return 0;
}
