#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 kol = 1;
        while (!q.empty()) {
          long x = q.front().first;
          long y = q.front().second;
          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 (x1 == x - 1) y1 = min(y1, y);
            if (x1 > x - 1) {
              x1 = x - 1;
              y1 = y;
            }
          }
          if (x + 1 < n && mass[x + 1][y] == 1) {
            kol++;
            q.push(make_pair(x + 1, y));
            mass[x + 1][y] = 0;
            if (x2 == x + 1) y2 = max(y1, y);
            if (x2 < x + 1) {
              x2 = x + 1;
              y2 = y;
            }
          }
          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 (kol > 80) {
          if (abs(y2 - y1) <= 2) {
            long double d =
                sqrt((double)(x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
            long s1 = d * d;
            long s2 = acos(-1.) * d * d / 4;
            if (abs(s1 - kol) > abs(s2 - kol))
              kol2++;
            else
              kol1++;
          } else
            kol1++;
        }
      }
    }
  cout << kol2 << " " << kol1;
}
