type PElem = ^Elem;
Elem = Record
data : string;
next : PElem;
end;
Lista = Record
head, tail : PElem;
end;
procedure initLista(var L : lista);
begin
new(L.head);
new(L.tail);
L.head^.data := '';
L.head^.next := L.tail;
L.tail^.data := 'zzzzzzzzzz';
L.tail^.next := NIL;
end;
procedure insert(var L : lista; s : string);
var p : PElem;
tmp : PElem;
begin
p := L.head;
while s > p^.next^.data do p := p^.next;
new(tmp);
tmp^.next := p^.next;
tmp^.data := s;
p^.next := tmp;
end;
procedure printList(L : lista);
var p : PELem;
begin
p := L.head^.next;
while p <> L.tail do
begin
write(p^.data,' ');
p := p^.next;
end;
writeln;
end;