#include <bits/stdc++.h>
using namespace std;
const int xy[4][2] = {{1, 0}, {0, -1}, {0, 1}, {-1, 0}};
int n, i, j, a[2222][2222], k1 = 0, k2 = 0, o[1111111][2];
long long ans = 0;
void white(int x, int y) {
  int o1 = 1, o2 = 0;
  o[0][0] = x;
  o[0][1] = y;
  while (o1 != o2) {
    int x1 = o[o2][0], y1 = o[o2][1];
    o2++;
    for (int i = 0; i < 4; i++) {
      x = x1 + xy[i][0];
      y = y1 + xy[i][1];
      if ((x >= 0) && (y >= 0) && (x < n) && (y < n) && (a[x][y])) {
        o[o1][0] = x;
        o[o1][1] = y;
        o1++;
        a[x][y] = 0;
      }
    }
  }
}
int main() {
  cin >> n;
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++) cin >> a[i][j];
  for (i = 0; i < n; i++)
    for (j = 0; j < n; j++)
      if (a[i][j]) {
        if (a[i + 5][j - 1])
          k1++;
        else
          k2++;
        white(i, j);
      }
  cout << k1 << " " << k2;
  return 0;
}
