#include <bits/stdc++.h>
using namespace std;
const int dx[5] = {0, -1, 1, 0, 0};
const int dy[5] = {0, 0, 0, -1, 1};
struct node {
  int x, y;
} q[2010 * 2010];
int pic[2010][2010], s[2010];
int n;
void init() {
  cin >> n;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++) cin >> pic[i][j];
}
void solve() {
  int ans1 = 0, ans2 = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (pic[i][j]) {
        s[i] = s[i + 1] = 0;
        int head = 1, tail = 1;
        q[1].x = i;
        q[1].y = j;
        s[i]++;
        pic[i][j] = 0;
        while (head <= tail) {
          for (int k = 1; k <= 4; k++)
            if (pic[q[head].x + dx[k]][q[head].y + dy[k]]) {
              tail++;
              q[tail].x = q[head].x + dx[k];
              q[tail].y = q[head].y + dy[k];
              pic[q[tail].x][q[tail].y] = 0;
              if (q[tail].x <= i + 2) s[q[tail].x]++;
            }
          head++;
        }
        if (s[i] == 1)
          ans1++;
        else
          ans2++;
      }
  cout << ans1 << ' ' << ans2 << endl;
}
int main() {
  ios::sync_with_stdio(false);
  init();
  solve();
  return 0;
}
