#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const long long INF_LL = 1000000000000000000LL;
const double pi = 2 * acos(0.0);
const int h = 2002;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
int n, cik, sqk;
bool a[h][h];
vector<pair<int, int> > q;
double dist(double x1, double y1, double x2, double y2) {
  return sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
}
int main() {
  scanf("%d", &n);
  int c;
  for (int i(0), _b(n); i < _b; ++i)
    for (int j(0), _b(n); j < _b; ++j) {
      scanf("%d", &c);
      a[i][j] = c;
    }
  for (int i(0), _b(n); i < _b; ++i)
    for (int j(0), _b(n); j < _b; ++j)
      if (a[i][j]) {
        q.clear();
        q.push_back(pair<int, int>(i, j));
        a[i][j] = 0;
        int c = 0;
        while (c < int((q).size())) {
          pair<int, int> u = q[c++];
          for (int d(0), _b(4); d < _b; ++d) {
            int ii = u.first + dx[d];
            int jj = u.second + dy[d];
            if (a[ii][jj]) {
              q.push_back(pair<int, int>(ii, jj));
              a[ii][jj] = 0;
            }
          }
        }
        int k = int((q).size());
        double x = 0, y = 0;
        for (int i(0), _b(k); i < _b; ++i) x += q[i].first, y += q[i].second;
        x /= k;
        y /= k;
        double r = 0;
        for (int i(0), _b(k); i < _b; ++i)
          r = max(r, dist(x, y, q[i].first, q[i].second));
        if (fabs(1 - pi * r * r / k) < 0.1)
          ++cik;
        else
          ++sqk;
      }
  printf("%d %d\n", cik, sqk);
  return 0;
}
