#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9;
int h, w;
vector<vector<int> > f;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
bool check(int x, int y) {
  return 0 <= x && x < w && 0 <= y && y < h && f[y][x];
}
vector<vector<int> > was;
double sumx, sumy;
int cnt;
void dfs1(int x, int y) {
  if (was[y][x] >= 1) return;
  was[y][x] = 1;
  sumx += x;
  sumy += y;
  cnt++;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (!check(nx, ny)) continue;
    dfs1(nx, ny);
  }
}
vector<double> dis;
void dfs2(int x, int y) {
  if (was[y][x] >= 2) return;
  was[y][x] = 2;
  bool bord = false;
  for (int i = 0; i < 4; i++) {
    int nx = x + dx[i], ny = y + dy[i];
    if (!check(nx, ny)) {
      bord = true;
      continue;
    }
    dfs2(nx, ny);
  }
  if (bord) dis.push_back((x - sumx) * (x - sumx) + (y - sumy) * (y - sumy));
}
int main() {
  while (scanf("%d", &h) >= 1) {
    w = h;
    f = vector<vector<int> >(h, vector<int>(w));
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++) scanf("%d", &f[y][x]);
    int c1 = 0, c2 = 0;
    was = vector<vector<int> >(h, vector<int>(w, 0));
    for (int y = 0; y < h; y++)
      for (int x = 0; x < w; x++)
        if (!was[y][x] && f[y][x]) {
          sumx = 0, sumy = 0;
          cnt = 0;
          dfs1(x, y);
          assert(cnt > 0);
          sumx /= cnt, sumy /= cnt;
          dis.clear();
          dfs2(x, y);
          sort(dis.begin(), dis.end());
          double diff = dis[((int)(dis).size()) - 1] - dis[0];
          if (diff > 200)
            c2++;
          else
            c1++;
        }
    printf("%d %d\n", c1, c2);
  }
  return 0;
}
