#include <bits/stdc++.h>
#pragma comment(linker, "/STACK:128000000")
using namespace std;
const double PI = acos(-1.0);
template <class T>
T SQR(const T &a) {
  return a * a;
}
void run() {
  int n;
  cin >> n;
  int A[2002][2002] = {0};
  for (int i = (0), ei = (n); i < ei; i++)
    for (int j = (0), ej = (n); j < ej; j++) scanf("%d", &A[i + 1][j + 1]);
  int dx[4] = {-1, 0, 1, 0};
  int dy[4] = {0, -1, 0, 1};
  int Cir = 0, Sq = 0;
  for (int i = (1), ei = (n); i < ei; i++)
    for (int j = (1), ej = (n); j < ej; j++)
      if (A[i][j]) {
        queue<pair<int, int> > q;
        A[i][j] = 0;
        q.push(pair<int, int>(i, j));
        int cnt = 1;
        pair<int, int> corn = pair<int, int>(i, j);
        while (!q.empty()) {
          int xi = q.front().first;
          int xj = q.front().second;
          if (xi > corn.first || xi == corn.first && xj < corn.first)
            corn = pair<int, int>(xi, xj);
          q.pop();
          for (int k = (0), ek = (4); k < ek; k++)
            if (A[xi + dx[k]][xj + dy[k]]) {
              cnt++;
              A[xi + dx[k]][xj + dy[k]] = 0;
              q.push(pair<int, int>(xi + dx[k], xj + dy[k]));
            }
        }
        double d = SQR(i - corn.first) + SQR(j - corn.second);
        double sq = PI * d / 4.0;
        if (fabs(sq - cnt) < 50)
          Cir++;
        else
          Sq++;
      }
  cout << Cir << ' ' << Sq << endl;
}
int main() {
  time_t beg = clock();
  run();
  return 0;
}
