#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
const int INF = 1e18;
int n, out[maxn], ans = 0;
set<int> g[maxn], g2[maxn];
bool scc() {
  vector<int> vv;
  for (int i = 1; i <= n; i++) vv.push_back(out[i]);
  sort(vv.begin(), vv.end());
  reverse(vv.begin(), vv.end());
  int sum = 0;
  for (int i = 0; i < n - 1; i++) {
    sum += vv[i];
    int x = i + 1;
    if (sum == ((x * (x - 1)) / 2) + x * (n - x)) return false;
  }
  return true;
}
void change(int v) {
  out[v] = n - 1 - (out[v]);
  vector<int> v1, v2;
  for (auto u : g[v]) {
    out[u]++;
    v1.push_back(u);
  }
  for (auto u : g2[v]) {
    out[u]--;
    v2.push_back(u);
  }
  g[v].clear();
  g2[v].clear();
  for (auto u : v1) g2[v].insert(u);
  for (auto u : v2) g[v].insert(u);
}
int main() {
  std::ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    string s1;
    cin >> s1;
    for (int j = 0; j < n; j++) {
      int x = s1[j] - '0';
      if (x) {
        out[i]++;
        g[i].insert(j + 1);
        g2[j + 1].insert(i);
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    change(i);
    ans += scc();
    change(i);
  }
  if (scc()) return cout << 0 << " " << 1, 0;
  if (ans > 0) return cout << 1 << " " << ans, 0;
  if (n == 4) return cout << -1, 0;
  if (n == 6) return cout << 2 << " " << 18, 0;
  return 0;
}
