const fi = '';
fo = '';
maxn = 500;
var n:longint;
a: array[1..maxn,1..maxn] of boolean;
l,r: array[1..maxn] of longint;
procedure enter;
var i,j,k,p:longint;
begin
readln(n);
for i:=1 to n do
begin
for j:=1 to n do
begin
read(p);
a[i,j]:=(p=1);
if a[i,j] then inc(l[i]);
end;
readln;
end;
for i:=1 to n do
for j:=1 to n do
for k:=1 to n do
if not a[i,j] and a[i,k] and a[k,j] then
begin
a[i,j]:=true;
inc(l[i]);
end;
end;
procedure solve;
var i,j:longint;
res:longint;
begin
res:=0;
for i:=1 to n do
if l[i]=n then
begin
inc(res);
r[res]:=i;
end;
writeln(res);
for i:=1 to res do
writeln(r[i]);
end;
begin
assign(input,fi);
reset(input);
assign(output,fo);
rewrite(output);
enter;
solve;
close(input);
close(output);
end.
ICAgIGNvbnN0IGZpID0gJyc7CiAgICAgICAgICBmbyA9ICcnOwogICAgICAgICAgbWF4biA9IDUwMDsKICAgIHZhciBuOmxvbmdpbnQ7CiAgICAgICAgYTogYXJyYXlbMS4ubWF4biwxLi5tYXhuXSBvZiBib29sZWFuOwogICAgICAgIGwscjogYXJyYXlbMS4ubWF4bl0gb2YgbG9uZ2ludDsKICAgIHByb2NlZHVyZSBlbnRlcjsKICAgIHZhciBpLGosayxwOmxvbmdpbnQ7CiAgICBiZWdpbgogICAgICByZWFkbG4obik7CiAgICAgIGZvciBpOj0xIHRvIG4gZG8KICAgICAgYmVnaW4KICAgICAgICBmb3Igajo9MSB0byBuIGRvCiAgICAgICAgYmVnaW4KICAgICAgICAgIHJlYWQocCk7CiAgICAgICAgICBhW2ksal06PShwPTEpOwogICAgICAgICAgaWYgYVtpLGpdIHRoZW4gaW5jKGxbaV0pOwogICAgICAgIGVuZDsKICAgICAgICByZWFkbG47CiAgICAgIGVuZDsKICAgICAgZm9yIGk6PTEgdG8gbiBkbwogICAgICBmb3Igajo9MSB0byBuIGRvCiAgICAgIGZvciBrOj0xIHRvIG4gZG8KICAgICAgaWYgbm90IGFbaSxqXSBhbmQgYVtpLGtdIGFuZCBhW2ssal0gdGhlbgogICAgICBiZWdpbgogICAgICAgIGFbaSxqXTo9dHJ1ZTsKICAgICAgICBpbmMobFtpXSk7CiAgICAgIGVuZDsKICAgIGVuZDsKICAgIHByb2NlZHVyZSBzb2x2ZTsKICAgIHZhciBpLGo6bG9uZ2ludDsKICAgICAgICByZXM6bG9uZ2ludDsKICAgIGJlZ2luCiAgICAgIHJlczo9MDsKICAgICAgZm9yIGk6PTEgdG8gbiBkbwogICAgICBpZiBsW2ldPW4gdGhlbgogICAgICBiZWdpbgogICAgICAgIGluYyhyZXMpOwogICAgICAgIHJbcmVzXTo9aTsKICAgICAgZW5kOwogICAgICB3cml0ZWxuKHJlcyk7CiAgICAgIGZvciBpOj0xIHRvIHJlcyBkbwogICAgICB3cml0ZWxuKHJbaV0pOwogICAgZW5kOwogICAgYmVnaW4KICAgICAgYXNzaWduKGlucHV0LGZpKTsKICAgICAgcmVzZXQoaW5wdXQpOwogICAgICBhc3NpZ24ob3V0cHV0LGZvKTsKICAgICAgcmV3cml0ZShvdXRwdXQpOwogICAgICBlbnRlcjsKICAgICAgc29sdmU7CiAgICAgIGNsb3NlKGlucHV0KTsKICAgICAgY2xvc2Uob3V0cHV0KTsKICAgIGVuZC4KICAgICA=