#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 5;
char s[maxn][maxn];
int deg[maxn], f[maxn];
bool check(int n) {
  memcpy(f, deg, sizeof(f));
  sort(f + 1, f + n + 1, greater<int>());
  int s = 0;
  for (int i = 1; i < n; ++i) {
    s += f[i];
    if (s == i * (i - 1) / 2 + i * (n - i)) return false;
  }
  return true;
}
void flip(int k, int n) {
  for (int i = 1; i <= n; ++i) {
    if (i == k) continue;
    swap(s[i][k], s[k][i]);
    if (s[i][k] == '0')
      deg[k]++, deg[i]--;
    else
      deg[k]--, deg[i]++;
  }
}
int main() {
  int n;
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf(" %s", s[i] + 1);
    for (int j = 1; j <= n; ++j) {
      if (s[i][j] == '1') deg[i]++;
    }
  }
  if (check(n)) return puts("0 1"), 0;
  int w = 0;
  for (int i = 1; i <= n; ++i) {
    flip(i, n);
    if (check(n)) w++;
    flip(i, n);
  }
  if (w)
    printf("1 %d\n", w);
  else if (n == 6)
    puts("2 18");
  else
    puts("-1");
  return 0;
}
