#include <bits/stdc++.h>
using namespace std;
bool gt(long double a, long double b) { return a > b + 1e-12; }
const int MAXN = 2048;
long long dist(pair<long long, long long> a, pair<long long, long long> b) {
  long long x = abs(a.first - b.first) + 1;
  long long y = abs(a.second - b.second) + 1;
  return x * x + y * y;
}
int n;
int a[MAXN][MAXN];
int mark[MAXN][MAXN];
int cnt = 0;
pair<int, int> start, farthest;
void dfs(int i, int j, int c) {
  if (i < 0 || j < 0 || i >= n || j >= n || a[i][j] == 0) return;
  if (mark[i][j] != c) return;
  if (mark[i][j] == 0) cnt++;
  mark[i][j]++;
  if (dist(start, pair<int, int>(i, j)) > dist(start, farthest))
    farthest = pair<int, int>(i, j);
  dfs(i - 1, j, c);
  dfs(i + 1, j, c);
  dfs(i, j - 1, c);
  dfs(i, j + 1, c);
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (register int i = (0); i < (int)(n); ++i)
    for (register int j = (0); j < (int)(n); ++j) cin >> a[i][j];
  int square = 0, circle = 0;
  for (register int i = (0); i < (int)(n); ++i)
    for (register int j = (0); j < (int)(n); ++j)
      if (a[i][j] && mark[i][j] == 0) {
        cnt = 0;
        start = farthest = pair<int, int>(i, j);
        dfs(i, j, 0);
        start = farthest;
        dfs(i, j, 1);
        long double d = sqrt(dist(start, farthest));
        long double sq = d * d / 2;
        long double ci = M_PI * (d / 2) * (d / 2);
        if (fabs(sq - cnt) < fabs(ci - cnt))
          square++;
        else
          circle++;
      }
  cout << circle << " " << square << endl;
  return 0;
}
