program graf;

const

N=3;

var

   map:array[1..N,1..N] of integer;

   road:array [1..N] of integer;

   incl:array[1..N] of boolean;

   start,finish:integer;

   found:boolean;

   i,j:integer;

 

procedure step(s,f,p:integer);

var

   i,c:integer;

begin

     if s=f then begin

     found:=TRUE;

     writeln('øëÿõ   ');

     for i:=1 to p-1 do

                     write(road[i],' ');

     end else begin

              for c:=1 to N do

                           begin

                           if(map[s,c]<> 0)and (NOT incl[c]) then begin

                                  road[p]:=c;

                                  incl[c]:=TRUE;

                                  step(c,f,p+1);

                                  incl[c]:=FALSE;

                                  road[p]:=0;

                                  end;

end;

end;

end;

begin

for i:=1 to N do road[i]:=0;

for i:=1 to N do incl[i]:=FALSE;

for i:=1 to N do

for j:=1 to N do

              read(map[i,j]);

 

readln(start);

readln(finish);

 

road[1]:=start;

incl [start]:=TRUE;

step(start,finish,2);

if not found then writeln('Âêàçàíi òî÷êè íå ç','''ºäíàíi');

end.