#include <bits/stdc++.h>
using namespace std;
const int MAXN = 2002;
int a[MAXN][MAXN], circle, square, mark[MAXN][MAXN], comp = 0,
                                                     ix[] =
                                                         {
                                                             1,
                                                             0,
                                                             -1,
                                                             0,
},
                                                     iy[] = {0, -1, 0, 1},
                                                     size[1000];
int n;
void DFS(int i, int j) {
  if (mark[i][j]) return;
  mark[i][j] = comp;
  size[comp]++;
  for (int x = 0; x < 4; x++)
    if (min(i + ix[x], j + iy[x]) >= 0 && max(i + ix[x], j + iy[x]) < n &&
        a[i + ix[x]][j + iy[x]])
      DFS(i + ix[x], j + iy[x]);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &a[i][j]);
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] && !mark[i][j]) {
        comp++;
        DFS(i, j);
      }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
      if (a[i][j] == 1 && a[i + 1][j] == 0 && a[i][j + 1] == 0) {
        int k = i, l = j;
        while (k >= 0 && a[k][j]) k--;
        while (l >= 0 && a[i][l]) l--;
        if (i - k == j - l) {
          int flag = 0, sz = 0;
          for (int o = k + 1; o <= i; o++)
            for (int p = l + 1; p <= j; p++)
              if (!a[o][p])
                flag++;
              else
                sz++;
          if (sz == size[mark[i][j]]) square++;
        }
      }
  printf("%d %d\n", comp - square, square);
  return 0;
}
