#include <bits/stdc++.h>
using namespace std;
const int mxn = 2048;
int n, mn, ans, w[mxn][mxn], a[mxn], b[mxn];
char s[mxn];
void rev(int u) {
  for (int i = 1; i <= n; ++i) {
    w[u][i] ^= 1, w[i][u] ^= 1;
    if (w[u][i])
      ++a[u], --a[i];
    else
      --a[u], ++a[i];
  }
}
bool cmp(const int &x, const int &y) { return a[x] < a[y]; }
bool check() {
  int sum = 0;
  sort(b + 1, b + n + 1, cmp);
  for (int i = 1; i < n; ++i) {
    sum += a[b[i]];
    if (sum == i * (i - 1) / 2) return 0;
  }
  return 1;
}
void dfs(int x, int cnt) {
  if (cnt > mn) return;
  if (x > n) {
    if (check())
      if (cnt < mn)
        mn = cnt, ans = 1;
      else
        ++ans;
    else
      ;
    return;
  }
  rev(x), dfs(x + 1, cnt + 1), rev(x);
  dfs(x + 1, cnt);
}
int main() {
  scanf("%d", &n);
  for (int i = 1; i <= n; ++i) {
    scanf("%s", s);
    for (int j = 1; j <= n; ++j) w[i][j] = s[j - 1] - '0', a[i] += w[i][j];
    b[i] = i;
  }
  if (check()) return puts("0 1"), 0;
  if (n <= 6) {
    mn = n;
    dfs(1, 0);
    for (int i = 1; i <= mn; ++i) ans *= i;
    if (!ans)
      puts("-1");
    else
      printf("%d %d\n", mn, ans);
    return 0;
  }
  for (int i = 1; i <= n; ++i) rev(i), ans += check(), rev(i);
  if (!ans)
    puts("-1");
  else
    printf("1 %d\n", ans);
  return 0;
}
