#include <bits/stdc++.h>
using namespace std;
template <class T>
inline void setmax(T &a, T b) {
  if (b > a) a = b;
}
template <class T>
inline void setmin(T &a, T b) {
  if (b < a) a = b;
}
const int maxn = 2100;
const long double Pi = 3.14159265358979323846;
int a[maxn][maxn], was[maxn][maxn], num, mx = 0, sx, sy, fr, sr;
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
void dfs(int x, int y) {
  num++;
  was[x][y] = 1;
  setmax(mx, (x - sx) * (x - sx) + (y - sy) * (y - sy));
  if (x == sx) fr++;
  if (x == sx + 1) sr++;
  for (int i = 0; i < 4; i++) {
    int xx = x + dx[i], yy = y + dy[i];
    if (a[xx][yy] && !was[xx][yy]) {
      dfs(xx, yy);
    }
  }
}
int main(void) {
  int n;
  scanf("%d\n", &n);
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      scanf("%d", &a[i][j]);
    }
  }
  memset(was, 0, sizeof(was));
  int ci = 0, re = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!was[i][j] && a[i][j]) {
        num = 0, mx = 0;
        sx = i, sy = j;
        fr = 0, sr = 0;
        dfs(i, j);
        cerr << fr << ' ' << sr << endl;
        if (fabs(Pi * mx / 4 - num) / num < 0.1)
          ci++;
        else
          re++;
      }
    }
  }
  cout << ci << ' ' << re << endl;
  return 0;
}
