#include <bits/stdc++.h>
using namespace std;
int matr[2000][2000];
bool used[2000][2000];
int n;
int main() {
  cin >> n;
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) scanf("%d", &matr[i][j]);
  int circ = 0, sq = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (used[i][j]) continue;
      if (matr[i][j] == 0) {
        used[i][j] = true;
        continue;
      }
      if (matr[i][j] == 1) {
        bool issq = true;
        int st = 0;
        int k1 = j;
        while (k1 < n && matr[i][k1] == 1) {
          if (i > 0 && matr[i - 1][k1] == 1) {
            issq = false;
            break;
          }
          k1++;
        }
        int k2 = i;
        while (k2 < n && matr[k2][j] == 1) {
          if (j > 0 && matr[k2][j - 1] == 1) {
            issq = false;
            break;
          }
          k2++;
        }
        if (issq) {
          sq++;
          for (int i1 = i; i1 <= min(n - 1, k2); i1++)
            for (int j1 = j; j1 <= min(n - 1, k1); j1++)
              if (matr[i1][j1] == 1) used[i1][j1] = true;
        } else {
          int kk = j;
          bool finished = true;
          while (kk < n && matr[i][kk] == 1) {
            if (i < n && matr[i + 1][kk] == 1) finished = false;
            used[i][kk] = true;
            kk++;
          }
          if (finished) circ++;
        }
      }
    }
  }
  cout << circ << " " << sq << endl;
  return 0;
}
