#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1.);
const long long inf = 10000000000000LL;
const int MAXN = 200000 + 13;
struct str {
  int id, h;
  char f;
};
char m[2001][2001];
int n;
int getform(const int a, const int b) {
  int x, y, dx, dy;
  for (dx = 10; a + dx < n && m[a + dx][b]; ++dx)
    ;
  for (dy = 10; b + dy < n && m[a][b + dy]; ++dy)
    ;
  if (dx == dy) {
    for (int i = 0; i < dx; ++i)
      for (int j = 0; j < dy; ++j) m[a + i][b + j] = 0;
    return 1;
  } else {
    for (int i = 0; i < dx; ++i) {
      y = b;
      if (m[a + i][y])
        while (666) {
          if (!y) break;
          if (m[a + i][y - 1])
            y--;
          else
            break;
        }
      else
        while (!m[a + i][y]) ++y;
      while (m[a + i][y] && y < n) m[a + i][y] = 0, ++y;
    }
    return 0;
  }
}
int main() {
  int k[2] = {}, r;
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) cin >> r, m[i][j] = r;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) {
      if (m[i][j]) {
        r = getform(i, j);
        k[r]++;
      }
    }
  cout << k[0] << ' ' << k[1] << endl;
  return 0;
}
