#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:16777216")
using namespace std;
int n;
bool c[2012][2012];
int mx[] = {-1, 0, 1, 0};
int my[] = {0, 1, 0, -1};
void dfs(int x, int y) {
  c[x][y] = false;
  for (int k = 0; k < (int)4; ++k) {
    int cx = x + mx[k];
    int cy = y + my[k];
    if (cx >= 0 && cx < n && cy >= 0 && cy < n && c[cx][cy]) dfs(cx, cy);
  }
}
int main(int argc, char **argv) {
  scanf("%d", &n);
  int cir = 0, sq = 0;
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)n; ++j) {
      int x;
      scanf("%d", &x);
      c[i][j] = x;
    }
  for (int i = 0; i < (int)n; ++i)
    for (int j = 0; j < (int)n; ++j)
      if (c[i][j]) {
        if ((!i || !c[i - 1][j]) && (!j || !c[i][j - 1]) && c[i + 1][j] &&
            !c[i][j - 1]) {
          int d = 1;
          bool fl = 0;
          while (j + d < n && c[i][j + d] && d < 30) {
            if (i && c[i - 1][j]) {
              fl = 1;
              break;
            }
            d++;
          }
          if (!fl) {
            dfs(i, j);
            if (d >= 15) {
              sq++;
            } else
              cir++;
          }
        }
      }
  cout << cir << ' ' << sq << endl;
  return 0;
}
