#include <bits/stdc++.h>
using namespace std;
int arr1[103][103];
string arr[103];
int checkthewinner (int x,int y)
{
int pp=arr[x-1][y-1]-48;
if (pp==1)
return x;
return y;
}
int next (int i,int j,int n)
{
if (i+j==n)
return i+j;
int varr=(i+j)%n;
return varr;
}
int main()
{
int n;
scanf ("%d",&n);
for (int i=0; i<n ; i++)
cin >> arr[i];
for (int i=1; i<=n ; i++)
arr1[i][next(i,1,n)]=1;
for (int length =2; length<n; ++length)
{
for (int beg=1; beg<=n; beg++)
{
int endd=next(beg,length,n);
for (int k=next(beg,1,n); k!=endd ;k=next(k,1,n))
if (arr1[beg][k]==1 && arr1[k][endd]==1 && (arr[beg-1][k-1]-48==1 || arr[endd-1][k-1]-48==1 ) )
arr1[beg][endd]=1;
}
}
int winners=0;
for (int i=1; i<=n ; i++)
for (int j=1; j<=n; j++)
if (arr1[i][j]==1 && arr1[j][i]==1)
{
int xxx=checkthewinner(i,j);
if (arr1[xxx][xxx]==0)
{
arr1[xxx][xxx]=1;
winners++;
}
}
printf ("%d\n", winners);
for (int i=1; i<=n;++i)
if(arr1[i][i]==1)
printf ("%d\n", i);
return 0;
}
I2luY2x1ZGUgPGJpdHMvc3RkYysrLmg+CnVzaW5nIG5hbWVzcGFjZSBzdGQ7CgogaW50IGFycjFbMTAzXVsxMDNdOwogc3RyaW5nIGFyclsxMDNdOwoKaW50IGNoZWNrdGhld2lubmVyIChpbnQgeCxpbnQgeSkKewogICAgaW50IHBwPWFyclt4LTFdW3ktMV0tNDg7CiAgICBpZiAocHA9PTEpCiAgICAgICAgcmV0dXJuIHg7CiAgICByZXR1cm4geTsKfQoKaW50IG5leHQgKGludCBpLGludCBqLGludCBuKQp7CiAgICBpZiAoaStqPT1uKQogICAgcmV0dXJuIGkrajsKCiAgICBpbnQgdmFycj0oaStqKSVuOwoKICAgIHJldHVybiB2YXJyOwp9CgppbnQgbWFpbigpCnsKICAgIGludCBuOwogICAgc2NhbmYgKCIlZCIsJm4pOwoKICAgIGZvciAoaW50IGk9MDsgaTxuIDsgaSsrKQogICAgICAgIGNpbiA+PiBhcnJbaV07CgogICAgIGZvciAoaW50IGk9MTsgaTw9biA7IGkrKykKICAgICAgICBhcnIxW2ldW25leHQoaSwxLG4pXT0xOwoKICAgICBmb3IgKGludCBsZW5ndGggPTI7IGxlbmd0aDxuOyArK2xlbmd0aCkKICAgICB7CiAgICAgICAgIGZvciAoaW50IGJlZz0xOyBiZWc8PW47IGJlZysrKQogICAgICAgICB7CiAgICAgICAgICAgIGludCBlbmRkPW5leHQoYmVnLGxlbmd0aCxuKTsKCiAgICAgICAgICAgICBmb3IgKGludCBrPW5leHQoYmVnLDEsbik7IGshPWVuZGQgO2s9bmV4dChrLDEsbikpCiAgICAgICAgICAgICAgICBpZiAoYXJyMVtiZWddW2tdPT0xICYmIGFycjFba11bZW5kZF09PTEgJiYgKGFycltiZWctMV1bay0xXS00OD09MSB8fCBhcnJbZW5kZC0xXVtrLTFdLTQ4PT0xICkgKQogICAgICAgICAgICAgICAgYXJyMVtiZWddW2VuZGRdPTE7CgogICAgICAgICB9CiAgICAgfQoJCglpbnQgd2lubmVycz0wOwoJCiAgIGZvciAoaW50IGk9MTsgaTw9biA7IGkrKykKICAgICAgICBmb3IgKGludCBqPTE7IGo8PW47IGorKykKICAgICAgICAgICAgaWYgKGFycjFbaV1bal09PTEgJiYgYXJyMVtqXVtpXT09MSkKICAgICAgICAgICAgewogICAgICAgICAgICBpbnQgeHh4PWNoZWNrdGhld2lubmVyKGksaik7CiAgICAgICAgICBpZiAoYXJyMVt4eHhdW3h4eF09PTApCiAgICAgICAgICB7CiAgICAgICAgICAgICAgYXJyMVt4eHhdW3h4eF09MTsKICAgICAgICAgICAgICB3aW5uZXJzKys7CiAgICAgICAgICB9CgogICAgICAgICAgICB9CgogCQkJcHJpbnRmICgiJWRcbiIsIHdpbm5lcnMpOwoKICAgICAgICAgICAgZm9yIChpbnQgaT0xOyBpPD1uOysraSkKICAgICAgICAgICAgICAgIGlmKGFycjFbaV1baV09PTEpCiAgICAgICAgICAgIHByaW50ZiAoIiVkXG4iLCBpKTsKCiAgICAgICAgICAgIHJldHVybiAwOwp9