#include <bits/stdc++.h>
int n, cnt, l, r, u, d, arr[2005][2005];
int dx[] = {1, -1, 0, 0}, dy[] = {0, 0, 1, -1};
void fill(int x, int y) {
  if (!arr[x][y]) return;
  cnt++;
  if (x > r || (x == r && y > d)) {
    r = x;
    d = y;
  }
  if (x < l || (x == l && y < u)) {
    l = x;
    u = y;
  }
  arr[x][y] = 0;
  for (int i = 0; i < 4; i++) {
    int newx = x + dx[i], newy = y + dy[i];
    if (newx < 0 || newx >= n || newy < 0 || newy >= n) continue;
    fill(newx, newy);
  }
}
int main() {
  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) scanf("%d", arr[i] + j);
  }
  int x = 0, y = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      if (!arr[i][j]) continue;
      cnt = 0;
      l = 1e9;
      r = 0;
      u = 1e9;
      d = 0;
      fill(i, j);
      if (cnt < 150) continue;
      int dia = (r - l) * (r - l) + (d - u) * (d - u);
      (cnt > dia * 1.1 / 2 ? x : y)++;
    }
  }
  printf("%d %d\n", x, y);
  return 0;
}
