#include <bits/stdc++.h>
using namespace std;
int main() {
  long n;
  cin >> n;
  vector<vector<long> > mass(n, vector<long>(n, 0));
  for (long i = 0; i < n; i++)
    for (long j = 0; j < n; j++) cin >> mass[i][j];
  long kol1 = 0;
  long kol2 = 0;
  for (long i = 0; i < n; i++)
    for (long j = 0; j < n; j++) {
      if (mass[i][j] == 1) {
        mass[i][j] = 0;
        queue<pair<long, long> > q;
        q.push(make_pair(i, j));
        long x1 = i, x2 = i, y1 = j, y2 = j;
        long long kol = 1;
        while (!q.empty()) {
          long x = q.front().first;
          long y = q.front().second;
          if (x1 == x) y1 = min(y1, y);
          if (x1 > x) {
            x1 = x;
            y1 = y;
          }
          if (x2 == x) y2 = max(y2, y);
          if (x2 < x) {
            x2 = x;
            y2 = y;
          }
          q.pop();
          if (x - 1 >= 0 && mass[x - 1][y] == 1) {
            kol++;
            q.push(make_pair(x - 1, y));
            mass[x - 1][y] = 0;
          }
          if (x + 1 < n && mass[x + 1][y] == 1) {
            kol++;
            q.push(make_pair(x + 1, y));
            mass[x + 1][y] = 0;
          }
          if (y - 1 >= 0 && mass[x][y - 1] == 1) {
            kol++;
            q.push(make_pair(x, y - 1));
            mass[x][y - 1] = 0;
          }
          if (y + 1 < n && mass[x][y + 1] == 1) {
            kol++;
            q.push(make_pair(x, y + 1));
            mass[x][y + 1] = 0;
          }
        }
        if (y2 == y1) {
          long double d = x2 - x1;
          long long s2 = acos(-1.) * d * d / 4;
          long long s1 = d * d / 2;
          if (abs(s1 - kol) > abs(s2 - kol))
            kol2++;
          else
            kol1++;
        } else
          kol1++;
      }
    }
  cout << kol2 << " " << kol1;
}
