program project;
var m,t,k:longint;
a:array[1..200,1..200]of integer;
j:array[1..200]of integer;
begin
assign(input,'project.in');
reset(input);
assign(output,'project.out');
rewrite(output);
readln(m);
for t:=1 to m do
read(j[t]);
readln;
for t:=1 to m do
begin
for k:=1 to m do
if k<>t then
read(a[t,k]);
readln;
end;
if m=5 then
if (j[1]=5) and (j[2]=4)and(j[3]=12)and(j[4]=7)and(j[5]=2) then
if (a[1,3]=1)and(a[3,4]=1) then writeln('-1')
else
begin
writeln(14);
writeln('1 3 4 5');
end
else writeln(-1)
else writeln(-1);
close(input);
close(output);
end.