#include <bits/stdc++.h>
using namespace std;
const int MaxN = 2000 + 5;
const int dx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
const int dy[] = {0, -1, 0, 1, -1, -1, 1, 1};
int N, A[MaxN][MaxN], B[MaxN][MaxN], ExtremeX[MaxN * MaxN],
    ExtremeY[MaxN * MaxN];
int main(void) {
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) scanf("%d", &A[i][j]);
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) B[i][j] = A[i][j];
  int idx = 0, ExtremeValue = 1 << 30, Cnt1 = 0, Cnt2 = 0;
  for (int i = 0; i < N; i++)
    for (int j = 0; j < N; j++) {
      if (!A[i][j]) continue;
      queue<int> X, Y;
      X.push(i);
      Y.push(j);
      A[i][j] = 0;
      int Cnt = 0;
      idx = 0;
      while (!X.empty()) {
        int CurrX = X.front();
        X.pop();
        int CurrY = Y.front();
        Y.pop();
        Cnt++;
        int CntExtreme = 0;
        for (int k = 0; k < 8; k++) {
          int NextX = CurrX + dx[k];
          int NextY = CurrY + dy[k];
          if ((NextX < 0) || (NextX >= N)) continue;
          if ((NextY < 0) || (NextY >= N)) continue;
          if (B[NextX][NextY]) CntExtreme++;
          if (!A[NextX][NextY]) continue;
          A[NextX][NextY] = 0;
          X.push(NextX);
          Y.push(NextY);
        }
        if (CntExtreme < ExtremeValue) {
          ExtremeValue = CntExtreme;
          idx = 0;
        }
        if (CntExtreme == ExtremeValue) {
          ExtremeX[idx] = CurrX;
          ExtremeY[idx] = CurrY;
          idx++;
        }
      }
      bool Square = true;
      if (idx == 4) {
        if ((ExtremeX[0] == ExtremeX[1]) && (ExtremeY[2] == ExtremeY[3]))
          Square = false;
        else if ((ExtremeX[0] == ExtremeX[2]) && (ExtremeY[1] == ExtremeY[3]))
          Square = false;
        else if ((ExtremeX[0] == ExtremeX[3]) && (ExtremeY[1] == ExtremeY[2]))
          Square = false;
        else if ((ExtremeX[1] == ExtremeX[2]) && (ExtremeY[0] == ExtremeY[3]))
          Square = false;
        else if ((ExtremeX[1] == ExtremeX[3]) && (ExtremeY[0] == ExtremeY[2]))
          Square = false;
        else if ((ExtremeX[2] == ExtremeX[3]) && (ExtremeY[0] == ExtremeY[1]))
          Square = false;
      }
      if (Square)
        Cnt2++;
      else
        Cnt1++;
    }
  printf("%d %d\n", Cnt1, Cnt2);
  return 0;
}
