Program FunList;

Type tPItem = ^tItem;
     tItem  = Record
                Next : tPItem;
                Content : String
              End;
Var Root : tPItem;
    Item : tPItem;

Procedure InsertItem ( Var List : tPItem; NewItem : tPItem );

Begin
  If (List <> Nil) And (NewItem^.Content > List^.Content) Then
    InsertItem(List^.Next,NewItem)
  Else Begin
    NewItem^.Next := List;
    List := NewItem
  End
End;

Procedure ShowList ( List : tPItem );

Begin
  If List <> Nil Then Begin
    WriteLn(List^.Content);
    ShowList(List^.Next)
  End
End;

Begin
  Root := Nil;
  While Not Eof Do Begin
    Item := New(tPItem);
    ReadLn(Item^.Content);
    InsertItem(Root,Item)
  End;
  ShowList(Root);
  While Root <> Nil Do Begin
    Item := Root;
    Root := Root^.Next;
    Dispose(Item)
  End
End.