#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 = 5;
const int T = 4, enough = 50;
struct both {
  int x, y;
};
int n;
int sum1, sum2;
both list[maxn * maxn];
int M[maxn][maxn];
int vis[maxn][maxn], use[maxn][maxn];
vector<both> chaf;
double sqr(double x) { return x * x; }
int main() {
  int i, j, k, l, r, x, y, nx, ny;
  int tries;
  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]);
  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 (tries = T; tries; --tries) {
          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 < enough) tries = 1;
        }
        if (r >= (maxx - minx) * (maxy - miny) / 4 &&
            (maxx - minx > 10 && maxy - miny > 10)) {
          cex = sux * 1. / r, cey = suy * 1. / r;
          for (k = 0; k < (int)chaf.size(); ++k)
            aver += sqrt((chaf[k].x - cex) * (chaf[k].x - cex) +
                         (chaf[k].y - cey) * (chaf[k].y - cey));
          aver /= (int)chaf.size();
          for (k = 0; k < (int)chaf.size(); ++k)
            faci += sqr(aver - sqrt((chaf[k].x - cex) * (chaf[k].x - cex) +
                                    (chaf[k].y - cey) * (chaf[k].y - cey)));
          faci /= (int)chaf.size();
          if (faci <= square_or_circle)
            ++sum1;
          else
            ++sum2;
        }
      }
  printf("%d %d\n", sum1, sum2);
  return 0;
}
