#include <bits/stdc++.h>
using namespace std;
const double eps = 1e-8;
char s[5007][5007];
vector<int> tmp;
int in[5007], out[5007];
int main() {
  int n, m;
  cin >> n;
  for (int i = 0; i < n; i++) scanf("%s", s[i]);
  memset(in, 0, sizeof(in));
  memset(out, 0, sizeof(out));
  for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++) {
      if (s[i][j] == '1') ++in[j], ++out[i];
    }
  bool ok = false;
  int id;
  for (int i = 0; i < n; i++) {
    int Sin = 0, Sout = 0, x = 0, y = 0;
    for (int j = 0; j < n; j++)
      if (s[i][j] == '1') {
        ++y;
        Sin += in[j];
        Sout += out[j];
      } else
        ++x;
    if (Sin != Sout + x * y) {
      ok = true;
      id = i;
      break;
    }
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      if (i != id && i != j && j != id)
        if (s[id][i] == '1' && s[i][j] == '1' && s[j][id] == '1') {
          cout << id + 1 << " " << i + 1 << " " << j + 1 << endl;
          return 0;
        }
  return 0;
}
