#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:300000000")
#pragma warning(disable : 4800)
using namespace std;
const double pi = 3.1415926535897932384626433832795;
template <class T>
T abs(const T &a) {
  return a >= 0 ? a : -a;
};
template <class T>
T sqr(const T &x) {
  return x * x;
}
int n;
bool visited[5000][5000];
bool visited2[5000][5000];
int a[5000][5000];
struct info {
  int size;
  int sumx, sumy;
};
info dfs(int x, int y) {
  info re;
  re.size = re.sumx = re.sumy = 0;
  if (visited2[x][y]) return re;
  visited2[x][y] = true;
  re.size = 1;
  re.sumx = x;
  re.sumy = y;
  for (int i = -1; i <= 1; i++)
    for (int j = -1; j <= 1; j++)
      if (abs(i) + abs(j) == 1) {
        int tox = x + i;
        int toy = y + j;
        if (a[tox][toy]) {
          info t = dfs(tox, toy);
          re.size += t.size;
          re.sumx += t.sumx;
          re.sumy += t.sumy;
        }
      }
  return re;
}
double dfs2(int x, int y, double cx, double cy) {
  if (visited[x][y]) return 0;
  visited[x][y] = true;
  double re = sqrt(sqr(x - cx) + sqr(y - cy));
  for (int i = -1; i <= 1; i++)
    for (int j = -1; j <= 1; j++)
      if (abs(i) + abs(j) == 1) {
        int tox = x + i;
        int toy = y + j;
        if (a[tox][toy]) {
          re = max(re, dfs2(tox, toy, cx, cy));
        }
      }
  return re;
}
bool isCircle(int x, int y) {
  info t = dfs(x, y);
  double cx = (double)t.sumx / t.size;
  double cy = (double)t.sumy / t.size;
  double r = dfs2(x, y, cx, cy);
  double mi = 2 * sqr(r);
  double ma = pi * sqr(r);
  return t.size > (mi + ma) / 2;
}
int main() {
  cin >> n;
  for (int i = 0; i < (n); i++)
    for (int j = 0; j < (n); j++) cin >> a[i + 1][j + 1];
  int sq = 0, cir = 0;
  for (int i = 1; i <= n; i++)
    for (int j = 1; j <= n; j++)
      if (a[i][j] && !visited[i][j]) {
        if (isCircle(i, j))
          cir++;
        else
          sq++;
      }
  cout << cir << ' ' << sq;
}
