#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:256000000")
using namespace std;
template <class T>
inline T sqr(T a) {
  return a * a;
}
int a[2000][2000];
bool was[2000][2000];
struct point {
  int x, y;
  point() {}
  point(int _x, int _y) {
    x = _x;
    y = _y;
  }
};
int r = 0, q = 0;
int n;
int dx[4] = {0, 0, 1, -1}, dy[4] = {-1, 1, 0, 0};
void dfs(const point &p) {
  was[p.x][p.y] = 1;
  for (int i = 0; i < 4; ++i) {
    point t(p.x + dx[i], p.y + dy[i]);
    if (t.x < 0 || t.x >= n || t.y < 0 || t.y >= n || was[t.x][t.y] ||
        !a[t.x][t.y])
      continue;
    dfs(t);
  }
}
void f(const point &p) {
  point c(p.x, p.y);
  int k = c.x;
  while (c.x != n && a[c.x++][c.y])
    ;
  int dx = c.x - k;
  k = p.y;
  while (c.y != n && a[p.x][c.y++])
    ;
  int dy = c.y - k;
  if (dx == dy)
    ++q;
  else
    ++r;
  dfs(p);
}
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] || was[i][j]) continue;
      f(point(i, j));
    }
  }
  cout << r << " " << q;
  return 0;
}
