#include <bits/stdc++.h>
using namespace std;
const int INF = 2e9;
const int MAXn = 2000 + 10;
bool mark[MAXn][MAXn];
int a[MAXn][MAXn];
int n;
inline bool ok(int r, int c) {
  return r >= 0 && c >= 0 && r < n && c < n && !mark[r][c] && a[r][c] == 1;
}
pair<int, int> topleft, botright;
void dfs(int r, int c) {
  topleft = min(topleft, pair<int, int>(r, c));
  botright = max(botright, pair<int, int>(r, c));
  mark[r][c] = true;
  if (ok(r + 1, c)) dfs(r + 1, c);
  if (ok(r, c + 1)) dfs(r, c + 1);
  if (ok(r, c - 1)) dfs(r, c - 1);
  if (ok(r - 1, c)) dfs(r - 1, c);
}
ostream& operator<<(ostream& cout, pair<int, int> p) {
  cout << "(" << p.first << "," << p.second << ")";
  return cout;
}
int main() {
  ios::sync_with_stdio(false);
  cin >> n;
  for (int i = 0, __e = n; i < __e; i++)
    for (int j = 0, __e = n; j < __e; j++) cin >> a[i][j];
  int sq = 0, cir = 0;
  for (int i = 0, __e = n; i < __e; i++)
    for (int j = 0, __e = n; j < __e; j++) {
      if (ok(i, j)) {
        topleft = pair<int, int>(1000000, 1000000);
        botright = pair<int, int>(-1, -1);
        dfs(i, j);
        if (abs(topleft.second - botright.second) < 5)
          cir++;
        else
          sq++;
      }
    }
  cout << cir << " " << sq << endl;
  return 0;
}
