#include <bits/stdc++.h>
void Get(int &T) {
  char C;
  bool F = 0;
  for (; C = getchar(), C < '0' || C > '9';)
    if (C == '-') F = 1;
  for (T = C - '0'; C = getchar(), C >= '0' && C <= '9'; T = T * 10 + C - '0')
    ;
  F && (T = -T);
}
int N;
int G[2005][2005];
void Init() {
  Get(N);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++) Get(G[i][j]);
}
double Dis(int X, int Y, int X2, int Y2) {
  double DX = X - X2;
  double DY = Y - Y2;
  return sqrt(DX * DX + DY * DY);
}
int QX[4000005];
int QY[4000005];
int L, R;
bool Visited[2005][2005];
int DX[] = {0, 0, 1, -1};
int DY[] = {1, -1, 0, 0};
int BFS(int X, int Y) {
  int Cnt = 1;
  QX[L = R = 1] = X;
  QY[1] = Y;
  Visited[X][Y] = 1;
  for (; L <= R; L++) {
    for (int i = 0; i <= 3; i++) {
      int NewX = QX[L] + DX[i];
      int NewY = QY[L] + DY[i];
      if (Visited[NewX][NewY] == 0 && NewX > 0 && NewX <= N && NewY > 0 &&
          NewY <= N && G[NewX][NewY] == G[X][Y]) {
        Visited[NewX][NewY] = 1;
        QX[++R] = NewX;
        QY[R] = NewY;
        Cnt++;
      }
    }
  }
  return Cnt;
}
int Top;
int ID[2005][2005];
int Fa[4000005];
double SumX[4000005];
double SumY[4000005];
double Sum[4000005];
double Max[4000005];
int Cnt[4000005];
int GetFa(int X) {
  if (Fa[X] == X) return Fa[X];
  return Fa[X] = GetFa(Fa[X]);
}
int Ans1, Ans2;
void Work() {
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (!Visited[i][j] && G[i][j] == 1) {
        int Ans = BFS(i, j);
        if (Ans <= 99) {
          for (int i = 1; i <= Ans; i++) {
            G[QX[i]][QY[i]] = !G[QX[i]][QY[i]];
          }
        }
      }
  memset(Visited, 0, sizeof Visited);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (!Visited[i][j] && G[i][j] == 0) {
        int Ans = BFS(i, j);
        if (Ans <= 99) {
          for (int i = 1; i <= Ans; i++) {
            G[QX[i]][QY[i]] = !G[QX[i]][QY[i]];
          }
        }
      }
  memset(Visited, 0, sizeof Visited);
  for (int i = 1; i <= N; i++)
    for (int j = 1; j <= N; j++)
      if (!Visited[i][j] && G[i][j] == 1) {
        int Ans = BFS(i, j);
        Top++;
        Fa[Top] = Top;
        for (int i = 1; i <= Ans; i++) {
          ID[QX[i]][QY[i]] = Top;
        }
      }
  for (int i = 1; i <= 2000; i++)
    for (int j = 1; j <= 2000; j++) {
      if (G[i][j] == 1) {
        for (int i2 = -5; i2 <= 5; i2++)
          for (int j2 = -(5 - std::abs(i2)); j2 + std::abs(i2) <= 5; j2++) {
            int X = i + i2;
            int Y = j + j2;
            if (X > 0 && X <= 2000 && Y > 0 && Y <= 2000 && G[X][Y] == 1 &&
                GetFa(ID[X][Y]) != GetFa(ID[i][j])) {
              int Ans1 = GetFa(ID[X][Y]), Ans2 = GetFa(ID[i][j]);
              Fa[Ans1] = Ans2;
            }
          }
      }
    }
  for (int i = 1; i <= 2000; i++)
    for (int j = 1; j <= 2000; j++) {
      Cnt[GetFa(ID[i][j])]++;
      SumX[GetFa(ID[i][j])] += i;
      SumY[GetFa(ID[i][j])] += j;
    }
  for (int i = 1; i <= Top; i++)
    if (Cnt[i] > 0) {
      SumX[i] /= Cnt[i];
      SumY[i] /= Cnt[i];
    }
  for (int i = 1; i <= 2000; i++)
    for (int j = 1; j <= 2000; j++) {
      double Dist = Dis(i, j, SumX[GetFa(ID[i][j])], SumY[GetFa(ID[i][j])]);
      Sum[GetFa(ID[i][j])] += Dist;
      if (Max[GetFa(ID[i][j])] < Dist) Max[GetFa(ID[i][j])] = Dist;
    }
  for (int i = 1; i <= Top; i++)
    if (Cnt[i] > 0) {
      Sum[i] /= Cnt[i];
      double Except2 = (Max[i] * 0.765195) - Sum[i] * sqrtl(2);
      double Except1 = (Max[i] * 2 / 3.) - Sum[i];
      if (Except1 < 0) Except1 = -Except1;
      if (Except2 < 0) Except2 = -Except2;
      if (Except1 < Except2)
        Ans1++;
      else
        Ans2++;
    }
}
void Output() { printf("%d %d\n", Ans1, Ans2); }
int main() {
  Init();
  Work();
  Output();
  return 0;
}
