program creere;
uses crt;
type ref=^elem;
     elem=record
                inf:string[15];
                leg:ref;
          end;
var vf,r:ref;
    cuv:string[15];
procedure creare{(var vf:ref)};
begin
   vf:=nil;
   readln(cuv);
   while cuv <>'.' do
     begin
       new(r);
       r^.inf:=cuv;
       r^.leg:=vf;
       vf:=r;
       readln(cuv);
     end;
end;
procedure parcurgere(vf:ref);
begin
  {if cuv='.' then writeln('stiva goala')
             else}
                begin
                  r:=vf;writeln;
                  repeat
                    writeln(r^.inf);
                    r:=r^.leg;
                  until r=nil;
                end;
end;
begin
clrscr;
creare;
parcurgere(vf);
readln;
end.