#include <bits/stdc++.h>
using namespace std;
int n;
int mat[2001][2001];
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
queue<int> q_x;
queue<int> q_y;
int countcirc = 0, countrec = 0;
void BFS_mark(int x, int y) {
  q_x.push(x);
  q_y.push(y);
  while (!q_x.empty()) {
    int xt = q_x.front();
    int yt = q_y.front();
    q_x.pop();
    q_y.pop();
    mat[xt][yt] = 0;
    for (int i = 0; i < 8; i++) {
      int xt1 = xt + dx[i];
      int yt1 = yt + dy[i];
      if (xt1 < 0 || xt1 > n - 1 || yt1 < 0 || yt1 > n - 1) continue;
      if (mat[xt1][yt1] == 0) continue;
      mat[xt1][yt1] = 0;
      q_x.push(xt1);
      q_y.push(yt1);
    }
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &mat[i][j]);
    }
  }
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (mat[i][j] == 1) {
        if (mat[i + 1][j - 1] == 1)
          countcirc++;
        else
          countrec++;
        BFS_mark(i, j);
      }
    }
  }
  printf("%d %d\n", countcirc, countrec);
  return 0;
}
