#include <bits/stdc++.h>
using namespace std;
const int maxn = 2000 + 55;
int a[maxn][maxn];
int n;
bool vis[maxn][maxn];
const int dx[] = {1, 1, 0, -1, -1, -1, 0, 1};
const int dy[] = {0, 1, 1, 1, 0, -1, -1, -1};
void shape(int x, int y, int dir) {
  int x1 = x, y1 = y, x2 = n, xl;
  while (1) {
    x1 = x;
    while (x1 < n && a[y1][x1]) {
      vis[y1][x1] = true;
      ++x1;
    }
    x2 = x1 - 1;
    ++y1;
    if (y1 == n) break;
    x1 = x;
    if (a[y1][x1]) {
      while (x1 >= 0 && a[y1][x1]) --x1;
      ++x1;
    } else {
      while (x1 <= x2 && !a[y1][x1]) ++x1;
      if (x1 > x2) break;
    }
    x = x1;
  }
}
bool isCircle(int x, int y) {
  if (x == 0 || !a[y + 1][x - 1])
    return false;
  else
    return true;
}
int main() {
  int i, j;
  scanf("%d", &n);
  for (i = 0; i < (int)(n); ++i) {
    for (j = 0; j < (int)(n); ++j) {
      scanf("%d", &a[i][j]);
    }
  }
  int cnt1 = 0, cnt2 = 0;
  for (i = 0; i < (int)(n); ++i) {
    for (j = 0; j < (int)(n); ++j) {
      if (!a[i][j] || vis[i][j]) continue;
      if (isCircle(j, i))
        ++cnt1;
      else
        ++cnt2;
      shape(j, i, 0);
    }
  }
  cout << cnt1 << " " << cnt2;
  return 0;
}
