#include <bits/stdc++.h>   using namespace std;   char a[5004][5004];   int vis[5004] = {0};   int fl = 0;   int n;   void dfs(int x, int par) {     if (fl == 1) return;     vis[x] = 1;     for (int i = 0; i < n; i++) {       if (a[x][i] ==  1  && a[i][par] ==  1 ) {         printf( %d %d %d n , par + 1, x + 1, i + 1);         fl = 1;         return;       }       if (vis[i] == 0 && a[x][i] ==  1 ) {         if (fl == 1) return;         dfs(i, x);         if (fl == 1) return;       }     }   }   int main() {     scanf( %d , &n);     for (int i = 0; i < n; i++) {       scanf( %s , a[i]);     }     for (int i = 0; i < n; i++) {       if (vis[i] == 0) {         dfs(i, i);       }     }     if (fl == 0) {       printf( -1 n );     }     return 0;   }   