#pragma GCC optimize(3)
#pragma GCC optimize(2)
#pragma GCC optimize("Ofast")
#pragma GCC optimize("inline")
#pragma GCC optimize("-fgcse")
#pragma GCC optimize("-fgcse-lm")
#pragma GCC optimize("-fipa-sra")
#pragma GCC optimize("-ftree-pre")
#pragma GCC optimize("-ftree-vrp")
#pragma GCC optimize("-fpeephole2")
#pragma GCC optimize("-ffast-math")
#pragma GCC optimize("-fsched-spec")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("-falign-jumps")
#pragma GCC optimize("-falign-loops")
#pragma GCC optimize("-falign-labels")
#pragma GCC optimize("-fdevirtualize")
#pragma GCC optimize("-fcaller-saves")
#pragma GCC optimize("-fcrossjumping")
#pragma GCC optimize("-fthread-jumps")
#pragma GCC optimize("-funroll-loops")
#pragma GCC optimize("-fwhole-program")
#pragma GCC optimize("-freorder-blocks")
#pragma GCC optimize("-fschedule-insns")
#pragma GCC optimize("inline-functions")
#pragma GCC optimize("-ftree-tail-merge")
#pragma GCC optimize("-fschedule-insns2")
#pragma GCC optimize("-fstrict-aliasing")
#pragma GCC optimize("-fstrict-overflow")
#pragma GCC optimize("-falign-functions")
#pragma GCC optimize("-fcse-skip-blocks")
#pragma GCC optimize("-fcse-follow-jumps")
#pragma GCC optimize("-fsched-interblock")
#pragma GCC optimize("-fpartial-inlining")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("-freorder-functions")
#pragma GCC optimize("-findirect-inlining")
#pragma GCC optimize("-fhoist-adjacent-loads")
#pragma GCC optimize("-frerun-cse-after-loop")
#pragma GCC optimize("inline-small-functions")
#pragma GCC optimize("-finline-small-functions")
#pragma GCC optimize("-ftree-switch-conversion")
#pragma GCC optimize("-foptimize-sibling-calls")
#pragma GCC optimize("-fexpensive-optimizations")
#pragma GCC optimize("-funsafe-loop-optimizations")
#pragma GCC optimize("inline-functions-called-once")
#pragma GCC optimize("-fdelete-null-pointer-checks")
#include<bits/stdc++.h>
#define ll long long
#define PB push_back
#define pii pair<int, int>
#define x first
#define y second
#define vct vector
using namespace std;
int vis[5005], n;
char g[5005][5005];
void dfs(int u, int f){
vis[u] = 1;
for(int v = 1; v <= n; v++){
if(g[u][v] == '0') continue;
if(g[v][f] == '1'){
printf("%d %d %d", f, u, v);
exit(0);
}
if(!vis[v]) dfs(v, u);
}
}
int main(){
scanf("%d", &n);
for(int i = 1; i <= n; i++) scanf("%s", g[i] + 1);
for(int i = 1; i <= n; i++)
if(!vis[i]) dfs(i, 0);
cout << -1;
return 0;
}
600C - Make Palindrome | 1669D - Colorful Stamp |
1669B - Triple | 1669A - Division |
1669H - Maximal AND | 1669E - 2-Letter Strings |
483A - Counterexample | 3C - Tic-tac-toe |
1669F - Eating Candies | 1323B - Count Subrectangles |
991C - Candies | 1463A - Dungeon |
1671D - Insert a Progression | 1671A - String Building |
1671B - Consecutive Points Segment | 1671C - Dolce Vita |
1669G - Fall Down | 4D - Mysterious Present |
1316B - String Modification | 1204A - BowWow and the Timetable |
508B - Anton and currency you all know | 1672A - Log Chopping |
300A - Array | 48D - Permutations |
677C - Vanya and Label | 1583B - Omkar and Heavenly Tree |
1703C - Cypher | 1511C - Yet Another Card Deck |
1698A - XOR Mixup | 1702E - Split Into Two Sets |