#include <bits/stdc++.h>
using namespace std;
inline void RS(char *s) { scanf("%s", s); }
template <class T>
inline void RD(T &x) {
  char c;
  for (c = getchar(); c < '0'; c = getchar())
    ;
  x = c - '0';
  for (c = getchar(); c >= '0'; c = getchar()) x = x * 10 + c - '0';
}
const int N = 5009;
vector<int> L;
char G[N];
int n, l, r;
int main() {
  RD(n), RS(G), L.push_back(1);
  for (int b____ = int(n), i = 2; i <= b____; ++i) {
    RS(G + 1), l = 0, r = i - 2;
    while (l <= r && G[L[l]] == '0') ++l;
    while (r >= 0 && G[L[r]] == '1') --r;
    if (l == r + 1) {
      L.insert(L.begin() + l, i);
    } else {
      printf("%d %d %d\n", L[l], L[r], i);
      return 0;
    }
  }
  puts("-1");
}
