#include <bits/stdc++.h>
int dx[4] = {-1, 0, 1, 0};
int dy[4] = {0, -1, 0, 1};
int n;
int map[2010][2010];
int vis[2010][2010];
int as, ac;
int go(int x, int y) {
  vis[y][x] = 1;
  int r = 1;
  for (int i = 0; i < 4; ++i) {
    int nx = x + dx[i], ny = y + dy[i];
    if (map[ny][nx] == 0 || vis[ny][nx] == 1) continue;
    r += go(nx, ny);
  }
  return r;
}
int chk(int x, int y, int r) {
  int ok = 1;
  for (int i = y; i < y + r && ok == 1; ++i)
    for (int j = x; j < x + r && ok == 1; ++j)
      if (map[i][j] != 1) ok = 0;
  return ok == 1;
}
int main(void) {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i)
    for (int j = 1; j <= n; ++j) scanf("%d", &map[i][j]);
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= n; ++j) {
      if (map[i][j] == 0 || vis[i][j] == 1) continue;
      int nd = go(j, i);
      int r = (int)sqrt(nd);
      if (nd != r * r)
        ++ac;
      else {
        if (chk(j, i, r) == 1)
          ++as;
        else
          ++ac;
      }
    }
  }
  printf("%d %d\n", ac, as);
  return 0;
}
