#include <bits/stdc++.h>
using namespace std;
int n;
int a[3005][3005];
int b[3005][3005];
int s[3005][3005];
pair<int, int> q[9000000];
int sum(int x1, int y1, int x2, int y2) {
  return s[y2][x2] - s[y2][x1 - 1] - s[y1 - 1][x2] + s[y1 - 1][x1 - 1];
}
int sum(int x, int y) {
  return sum(x - 4, y - 4, x + 4, y + 4) - sum(x - 4, y - 4, x - 3, y - 3) -
         sum(x - 4, y + 3, x - 3, y + 4) - sum(x + 3, y - 4, x + 4, y - 3) -
         sum(x + 3, y + 3, x + 4, y + 4) - a[x - 4][y - 2] - a[x - 4][y + 2] -
         a[x - 2][y - 4] - a[x - 2][y + 4] - a[x + 2][y - 4] - a[x + 2][y + 4] -
         a[x + 4][y - 2] - a[x + 4][y + 2];
}
int look(int x, int y) {
  int td = 0;
  int sz = 1;
  int cx, cy;
  long long sx = 0, sy = 0;
  int max2 = 0;
  q[0].first = x;
  q[0].second = y;
  b[y][x] = 0;
  while (td < sz) {
    x = q[td].first;
    y = q[td].second;
    if (b[y - 1][x] == 1) {
      b[y - 1][x] = 0;
      q[sz].first = x;
      q[sz].second = y - 1;
      sz++;
    }
    if (b[y + 1][x] == 1) {
      b[y + 1][x] = 0;
      q[sz].first = x;
      q[sz].second = y + 1;
      sz++;
    }
    if (b[y][x - 1] == 1) {
      b[y][x - 1] = 0;
      q[sz].first = x - 1;
      q[sz].second = y;
      sz++;
    }
    if (b[y][x + 1] == 1) {
      b[y][x + 1] = 0;
      q[sz].first = x + 1;
      q[sz].second = y;
      sz++;
    }
    td++;
  }
  for (int i = 0; i < sz; i++) {
    sx += q[i].first;
    sy += q[i].second;
  }
  cx = sx / sz;
  cy = sy / sz;
  for (int i = 0; i < sz; i++) {
    max2 = max(max2, (q[i].first - cx) * (q[i].first - cx) +
                         (q[i].second - cy) * (q[i].second - cy));
  }
  if (sz > max2 * 3) return 1;
  return 2;
}
int main() {
  int circles = 0, squares = 0;
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      scanf("%d", &a[i + 500][j + 500]);
    }
  }
  for (int i = 1; i < 3000; i++) {
    for (int j = 1; j < 3000; j++) {
      s[i][j] = s[i][j - 1] + a[i][j];
    }
  }
  for (int i = 100; i < 2900; i++) {
    for (int j = 100; j < 2900; j++) {
      int t = 33 * a[i][j];
      if (t >= 30) {
        b[i][j] = 1;
      }
    }
  }
  for (int i = 100; i < 2900; i++) {
    for (int j = 100; j < 2900; j++) {
      if (b[i][j] == 1) {
        int t = look(j, i);
        if (t == 1) {
          circles++;
        } else {
          squares++;
        }
      }
    }
  }
  cout << circles << " " << squares;
  return 0;
}
