#include <bits/stdc++.h>
using namespace std;
int a[2222][2222];
int n;
bool used[2222][2222];
inline void dfs(int i, int j) {
  if (i < 0 || j < 0 || i >= n || j >= n || a[i][j] == 0 || used[i][j]) return;
  used[i][j] = 1;
  dfs(i, j - 1);
  dfs(i, j + 1);
  dfs(i - 1, j);
  dfs(i + 1, j);
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  int c = 0, k = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j)
      if (a[i][j] == 1 && !used[i][j]) {
        int len = 1;
        while (j + len < n && a[i][j + len] == 1) ++len;
        if (len >= 15) {
          ++k;
          dfs(i, j);
        } else {
          ++c;
          dfs(i, j);
        }
      }
  }
  printf("%d %d\n", c, k);
  return 0;
}
