Const n=5
var
a:array [1..n,1..n] of integer;
d:array [1..n] of integer;
i,j:integer;
begin
for i:=1 to 5 do
for j:=1 to 3 do
readln(a[i,j]);
for i:=1 to 5 do begin
for j:=1 to 3 do begin
if a[i,j]>0 then
d[i]:=d[i]+1;
end;
if d[i]=3 then
d[i]:=i
else
d[i]:=0;
end;
for i:=1 to 5 do
if d[i]>0 then
writeln(d[i]);
end.