#include <bits/stdc++.h>
using namespace std;
int n, a[2002][2002], vis[2002][2002];
int square, circle = 0;
bool inside(int x, int y) { return (0 <= x && x < n && 0 <= y && y < n); }
bool isBorder(int x, int y) {
  int counter = 0;
  for (int i = (-1), _b = (1); i <= _b; i++)
    for (int j = (-1), _b = (1); j <= _b; j++) {
      int xx = x + i, yy = y + j;
      if (!inside(xx, yy) || !a[xx][yy]) counter++;
    }
  return counter >= 2;
}
bool bfs(int x, int y) {
  pair<int, int> minX(x, y), minY(x, y), maxX(x, y), maxY(x, y);
  int counter = 0, cMinX = 0, cMaxX = 0, cMinY = 0, cMaxY = 0;
  queue<pair<int, int> > q;
  q.push(pair<int, int>(x, y));
  vis[x][y] = true;
  while (!q.empty()) {
    x = q.front().first, y = q.front().second;
    q.pop();
    for (int i = (-1), _b = (1); i <= _b; i++)
      for (int j = (-1), _b = (1); j <= _b; j++)
        if (inside(x + i, y + j) && !vis[x + i][y + j] && a[x + i][y + j]) {
          vis[x + i][y + j] = true;
          q.push(pair<int, int>(x + i, y + j));
        }
    counter++;
    if (x <= minX.first) {
      if (x < minX.first) cMinX = 0;
      minX = pair<int, int>(x, y);
      cMinX++;
    }
    if (x >= maxX.first) {
      if (x > maxX.first) cMaxX = 0;
      maxX = pair<int, int>(x, y);
      cMaxX++;
    }
    if (y <= minY.second) {
      if (x < minY.second) cMinY = 0;
      minY = pair<int, int>(x, y);
      cMinY++;
    }
    if (y >= maxY.second) {
      if (y > maxY.first) cMaxY = 0;
      maxY = pair<int, int>(x, y);
      cMaxY++;
    }
  }
  if (abs(counter - x * y) <= 2) return true;
  if (cMinX <= 2) return false;
  return true;
}
int main() {
  scanf("%d", &n);
  for (int i = 0, _n = (n); i < _n; i++)
    for (int j = 0, _n = (n); j < _n; j++)
      scanf("%d", &a[i][j]), vis[i][j] = false;
  square = circle = 0;
  for (int i = 0, _n = (n); i < _n; i++)
    for (int j = 0, _n = (n); j < _n; j++)
      if (a[i][j] && !vis[i][j]) {
        if (bfs(i, j))
          square++;
        else
          circle++;
      }
  printf("%d %d\n", circle, square);
  return 0;
}
