#include <bits/stdc++.h>
using namespace std;
const int maxn = 2010;
const int dir[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
const double square_or_circle = 2.5;
const int enough = 20;
struct both {
  int x, y;
};
int n;
int sum1, sum2;
both list[maxn * maxn];
int M[maxn][maxn], N[maxn][maxn];
int vis[maxn][maxn], use[maxn][maxn];
vector<both> chaf;
int main() {
  int i, j, k, l, r, x, y, nx, ny;
  int maxx, maxy, minx, miny;
  int sux, suy;
  double cex, cey;
  double aver, faci;
  scanf("%d\n", &n);
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j) scanf("%d", &M[i][j]);
  int Ti = 10;
  while (Ti--) {
    for (i = 1; i <= n; ++i)
      for (j = 1; j <= n; ++j)
        N[i][j] = (M[i - 1][j] + M[i][j - 1] + M[i + 1][j] + M[i][j + 1] +
                   M[i][j]) >= 3;
    for (i = 1; i <= n; ++i)
      for (j = 1; j <= n; ++j) M[i][j] = N[i][j];
  }
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j)
      if (!vis[i][j]) {
        for (list[l = r = 1] = (both){i, j}; l <= r; ++l) {
          x = list[l].x, y = list[l].y;
          for (k = 0; k < 4; ++k) {
            nx = x + dir[k][0], ny = y + dir[k][1];
            if (nx && ny && nx <= n && ny <= n)
              if (!vis[nx][ny] && M[nx][ny] == M[i][j])
                vis[nx][ny] = true, list[++r] = (both){nx, ny};
          }
        }
        if (r <= enough) {
          k = M[i][j] ^ 1;
          for (l = 1; l <= r; ++l) M[list[l].x][list[l].y] = k;
        }
      }
  memset(vis, 0, sizeof(vis));
  for (i = 1; i <= n; ++i)
    for (j = 1; j <= n; ++j)
      if (!vis[i][j] && M[i][j]) {
        chaf.clear();
        vis[i][j] = true;
        chaf.push_back((both){i, j});
        l = 1, r = 0;
        maxx = 0, maxy = 0, minx = n, miny = n;
        sux = 0, suy = 0;
        aver = 0, faci = 0;
        for (k = 0; k < (int)chaf.size(); ++k) list[++r] = chaf[k];
        chaf.clear();
        for (; l <= r; ++l) {
          x = list[l].x, y = list[l].y;
          sux += x, suy += y;
          maxx = max(maxx, x), maxy = max(maxy, y);
          minx = min(minx, x), miny = min(miny, y);
          for (k = 0; k < 4; ++k) {
            nx = x + dir[k][0], ny = y + dir[k][1];
            if (nx && ny && nx <= n && ny <= n)
              if (!vis[nx][ny] && M[nx][ny])
                vis[nx][ny] = true, list[++r] = (both){nx, ny};
              else if (!use[nx][ny] && !M[nx][ny])
                use[nx][ny] = true, chaf.push_back((both){nx, ny});
          }
        }
        if (r >= (maxx - minx) * (maxy - miny) / 4 &&
            (maxx - minx > 10 && maxy - miny > 10) && r >= 150) {
          cex = sux * 1. / r, cey = suy * 1. / r;
          for (k = 1; k <= r; ++k)
            aver = max(aver, sqrt((list[k].x - cex) * (list[k].x - cex) +
                                  (list[k].y - cey) * (list[k].y - cey)));
          if (r > square_or_circle * aver * aver)
            ++sum1;
          else
            ++sum2;
        }
      }
  printf("%d %d\n", sum1, sum2);
  return 0;
}
