#include <bits/stdc++.h>
using namespace std;
vector<pair<int, int> > vec[4000000];
int bit[2005][2005], prt[4000005], n;
bool chk[4000005];
inline int h(int x, int y) { return (x - 1) * n + y; }
inline bool legal(int x, int y) {
  if (x <= 0 || x > n) return false;
  if (y <= 0 || y > n) return false;
  return true;
}
int find(int x) {
  if (prt[x] == 0) return x;
  prt[x] = find(prt[x]);
  return prt[x];
}
void clear(int x, int y, int c) {
  int i, j, cnt = 0;
  for (i = -2; i <= 2; i++)
    for (j = -2; j <= 2; j++)
      if (i != 0 || j != 0)
        if (legal(x + i, y + j) && bit[x + i][y + j] == c) cnt++;
  if (cnt > 10) bit[x][y] = c ^ 1;
}
void join(int x, int y) {
  int i, j;
  for (i = -1; i <= 1; i++)
    for (j = -1; j <= 1; j++)
      if (i != 0 || j != 0)
        if (bit[x][y])
          if (find(h(x, y)) != find(h(x + i, y + j)))
            prt[find(h(x, y))] = find(h(x + i, y + j));
}
void renew() {
  int i, j;
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (bit[i][j]) vec[find(h(i, j))].push_back(make_pair(i, j));
}
int judge(int num) {
  double xsum = 0, ysum = 0;
  double x0, y0, dis, maxdis = 0, sum = 0;
  vector<pair<int, int> >::iterator iter = vec[num].begin();
  int cnt = 0, m = vec[num].size();
  if (m < 15) return -1;
  for (; iter != vec[num].end(); iter++)
    xsum += iter->first, ysum += iter->second;
  x0 = xsum / m;
  y0 = ysum / m;
  for (iter = vec[num].begin(); iter != vec[num].end(); iter++) {
    dis = (iter->first - x0) * (iter->first - x0);
    dis += (iter->second - y0) * (iter->second - y0);
    dis = sqrt(dis);
    if (dis > maxdis) maxdis = dis;
  }
  for (iter = vec[num].begin(); iter != vec[num].end(); iter++) {
    dis = (iter->first - x0) * (iter->first - x0);
    dis += (iter->second - y0) * (iter->second - y0);
    dis = sqrt(dis);
    sum += dis;
  }
  sum /= m;
  if (fabs(sum - 2 * maxdis / 3) < 1) return 1;
  return 2;
  return -1;
}
int main() {
  int i, j, sq = 0, cir = 0, tmp;
  scanf("%d", &n);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++) scanf("%d", &bit[i][j]);
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (bit[i][j]) join(i, j);
  renew();
  for (i = 1; i <= n; i++)
    for (j = 1; j <= n; j++)
      if (bit[i][j] && !chk[find(h(i, j))]) {
        chk[find(h(i, j))] = true;
        tmp = judge(find(h(i, j)));
        if (tmp == 2) sq++;
        if (tmp == 1) cir++;
      }
  printf("%d %d\n", cir, sq);
}
