#include <bits/stdc++.h>
using namespace std;
ifstream in("easy_1.in");
ofstream out("out.txt");
int n;
vector<vector<char> > A;
void dfs(int i, int j, int& sum, int x, int y, bool& sq) {
  if (A[i][j] != '1') return;
  A[i][j] = 0;
  sum++;
  if (i < x) sq = false;
  if (j < y) sq = false;
  if (i > 0) dfs(i - 1, j, sum, x, y, sq);
  if (j > 0) dfs(i, j - 1, sum, x, y, sq);
  if (j < n) dfs(i, j + 1, sum, x, y, sq);
  if (i < n) dfs(i + 1, j, sum, x, y, sq);
}
int main() {
  int a = 0, b = 0;
  cin >> n;
  A.assign(n, vector<char>(n));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) cin >> A[i][j];
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      int sum = 0;
      bool sq = true;
      if (A[i][j] == '1') {
        dfs(i, j, sum, i, j, sq);
        if (sq)
          a++;
        else
          b++;
      }
    }
  }
  cout << b << ' ' << a;
  return 0;
}
