#include <bits/stdc++.h>
using namespace std;
const int N = 2500;
int arr[N][N];
bool visited[N][N];
int n;
const double eps = 1e-8;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
bool valid(int x, int y) {
  return x >= 0 && x < n && y >= 0 && y < n && !visited[x][y] && arr[x][y] == 1;
}
bool is_circle(int x, int y) {
  queue<int> qx, qy;
  qx.push(x);
  qy.push(y);
  visited[x][y] = true;
  vector<pair<int, int> > v;
  while (!qx.empty()) {
    int x = qx.front();
    qx.pop();
    int y = qy.front();
    qy.pop();
    v.push_back(pair<int, int>(x, y));
    for (int i = 0; i < 4; i++) {
      int nx = x + dx[i], ny = y + dy[i];
      if (valid(nx, ny)) {
        visited[nx][ny] = true;
        qx.push(nx);
        qy.push(ny);
      }
    }
  }
  int minx = n, maxx = 0, miny = n, maxy = 0;
  for (int i = 0; i < v.size(); i++) {
    minx = min(minx, v[i].first);
    maxx = max(maxx, v[i].first);
    miny = min(miny, v[i].second);
    maxy = max(maxy, v[i].second);
  }
  int rad = (maxx - minx + 3) / 2;
  double cx = (maxx + minx) * 0.5;
  double cy = (maxy + miny) * 0.5;
  double rad2 = rad * rad;
  double max_diff = 0;
  double diff = rad2 - v.size() / acos(-1.0);
  return diff > 0;
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &arr[i][j]);
    }
  }
  memset(visited, 0, sizeof visited);
  int circles = 0, squares = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (arr[i][j] && !visited[i][j]) {
        if (is_circle(i, j)) {
          circles++;
        } else {
          squares++;
        }
      }
    }
  }
  cout << circles << " " << squares << endl;
  return 0;
}
