#include <bits/stdc++.h>
using namespace std;
int n;
int a[2005][2005];
bool used[2005][2005];
int l, r, u, d;
int lx, ly, rx, ry, ux, uy, dx, dy;
pair<int, int> mp(int x, int y) { return make_pair(x, y); }
int bfs(int x, int y) {
  int res = 0;
  queue<pair<int, int> > q;
  q.push(mp(x, y));
  used[x][y] = true;
  l = d = 1000000;
  r = u = -1000000;
  while (!q.empty()) {
    ++res;
    pair<int, int> cur = q.front();
    q.pop();
    int i = cur.first;
    int j = cur.second;
    if (j < l) {
      l = j;
      lx = i;
      ly = j;
    }
    if (j >= r) {
      r = j;
      rx = i;
      ry = j;
    }
    if (i < d) {
      d = i;
      dx = i;
      dy = j;
    }
    if (i >= u) {
      u = i;
      ux = i;
      uy = j;
    }
    r = max(j, r);
    d = min(i, d);
    u = max(i, u);
    if (i + 1 < n && a[i + 1][j] == 1 && !used[i + 1][j]) {
      q.push(mp(i + 1, j));
      used[i + 1][j] = true;
    }
    if (i > 0 && a[i - 1][j] == 1 && !used[i - 1][j]) {
      q.push(mp(i - 1, j));
      used[i - 1][j] = true;
    }
    if (j + 1 < n && a[i][j + 1] == 1 && !used[i][j + 1]) {
      q.push(mp(i, j + 1));
      used[i][j + 1] = true;
    }
    if (j > 0 && a[i][j - 1] == 1 && !used[i][j - 1]) {
      q.push(mp(i, j - 1));
      used[i][j - 1] = true;
    }
  }
  return res;
}
int main() {
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) scanf("%d", &a[i][j]);
  int c = 0, r = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (a[i][j] == 1 && !used[i][j]) {
        int res = bfs(i, j);
        if (lx == rx && dy == uy) {
          int side = lx - dx + 1;
          int sqr = side * side + (side - 1) * (side - 1);
          if (res == sqr)
            ++r;
          else
            ++c;
        } else
          ++r;
      }
      if (a[i][j] == 0) used[i][j] = true;
    }
  cout << c << endl << r << endl;
  return 0;
}
