#include<iostream>
using namespace std;
int Num[100],Low[100],Father[100];
bool Mark[100],Map[100][100],Cutpoint[100];
int time,n;
void DFS(int x)
{
Mark[x]=true;
time++;
Low[x]=Num[x]=time;
for(int i=0;i<n;i++)
{
if(Map[x][i]!=0)
{
if(Mark[i]==0)
{
Father[i]=x;
DFS(i);
Low[x]=min(Low[x],Low[i]);
}
else
Low[x]=min(Low[x],Num[i]);
}
}
return ;
}
void Solve()
{
cin>>n;
time=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>Map[i][j];
DFS(0);
int count=0;
for(int i=0;i<n;i++)
{
if(Low [i] >= Num[Father[i]]&&Father[i]!=0)
Cutpoint[Father[i]]=true;
if(Father[i]==0&&i!=0)
count++;
}
if(count>1)
Cutpoint[0]=true;
for(int i=0;i<n;i++)
if(Cutpoint[i])
cout<<i<<" ";
cout<<endl;
}
int main()
{
Solve();
return 0;
}
using namespace std;
int Num[100],Low[100],Father[100];
bool Mark[100],Map[100][100],Cutpoint[100];
int time,n;
void DFS(int x)
{
Mark[x]=true;
time++;
Low[x]=Num[x]=time;
for(int i=0;i<n;i++)
{
if(Map[x][i]!=0)
{
if(Mark[i]==0)
{
Father[i]=x;
DFS(i);
Low[x]=min(Low[x],Low[i]);
}
else
Low[x]=min(Low[x],Num[i]);
}
}
return ;
}
void Solve()
{
cin>>n;
time=0;
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>Map[i][j];
DFS(0);
int count=0;
for(int i=0;i<n;i++)
{
if(Low [i] >= Num[Father[i]]&&Father[i]!=0)
Cutpoint[Father[i]]=true;
if(Father[i]==0&&i!=0)
count++;
}
if(count>1)
Cutpoint[0]=true;
for(int i=0;i<n;i++)
if(Cutpoint[i])
cout<<i<<" ";
cout<<endl;
}
int main()
{
Solve();
return 0;
}