#include <bits/stdc++.h>
using namespace std;
const int N = 2020;
int n, Dout[N], d[N];
bool mat[N][N];
void rev(int v) {
  for (int i = 0; i < n; i++) {
    mat[i][v] ^= 1;
    if (mat[i][v])
      Dout[i]++;
    else
      Dout[i]--;
  }
  for (int j = 0; j < n; j++) {
    mat[v][j] ^= 1;
    if (mat[v][j])
      Dout[v]++;
    else
      Dout[v]--;
  }
}
bool check() {
  for (int i = 0; i < n; i++) d[i] = Dout[i];
  sort(d, d + n, greater<int>());
  int sum = d[0];
  for (int i = 1; i < n; i++) {
    if (sum >= i * (i - 1) / 2 + i * (n - i)) return false;
    sum += d[i];
  }
  return true;
}
signed main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    for (int j = 0; j < n; j++) {
      mat[i][j] = s[j] - '0';
      Dout[i] += mat[i][j];
    }
  }
  if (check()) {
    cout << "0 1\n";
    return 0;
  }
  int ans = -1, cnt = 0;
  for (int i = 0; i < n; i++) {
    rev(i);
    if (check()) {
      cnt++;
      ans = 1;
    }
    rev(i);
  }
  if (ans + 1) {
    cout << ans << " " << cnt << "\n";
    return 0;
  }
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      rev(i);
      rev(j);
      if (check()) cnt++;
      rev(i);
      rev(j);
    }
  if (cnt)
    cout << 2 << " " << cnt << "\n";
  else
    cout << "-1\n";
}
