#include<iostream> #include<cstdio> #include<cstring> using namespace std; const int maxn=55; int n; bool g[maxn][maxn]; bool found; int len[maxn],list[maxn][maxn],ans,mc[maxn]; void dfs(int size) { if(len[size]==0){ if(size>ans){ ans=size; found=true; } } for(int k=0;k<len[size]&&!found;k++){ if(size+len[size]-k<=ans){ break; } int i=list[size][k]; if(size+mc[i]<=ans){ break; } len[size+1]=0; for(int j=k+1;j<len[size];j++){ if(g[i][list[size][j]]){ list[size+1][len[size+1]++]=list[size][j]; } } dfs(size+1); } } void max_cluster() { mc[n]=ans=1; for(int i=n-1;i;i--){ found=false; len[1]=0; for(int j=i+1;j<=n;j++){ if(g[i][j]){ list[1][len[1]++]=j; } } dfs(1); mc[i]=ans; } } int main() { while(scanf("%d",&n)!=EOF&&n){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ scanf("%d",&g[i][j]); } } max_cluster(); printf("%d ",ans); } return 0; }