и находятся во входном файле.
Что -то я никак не могу сообразить.

Type
te=string;
pe=^el;
el=Record
inf:te;
next:pe
end;
Var sag,p,q,sag2:pe;
n,i,j:integer;
procedure COPY (sag:pe; Var sag2:pe); //Копирование списка sag в список sag2
begin
if sag=nil then sag2:=nil
else begin
new (sag2);
sag2^.inf:=sag^.inf;
COPY (sag^.next, sag2^.next)
end;
end;
procedure PRINT (sag:pe);// вывод на экран
Var q:pe;
begin
q:=sag^.next;
while q<>nil do
begin write (q^.inf, ' ');
q:=q^.next
end;
end;
{--------------------------------------------------------------------------------}
begin
New (sag);
sag^.next:=Nil;
p:=sag;
writeln ('Zadayte kol-vo elementov LOS');
readln (n);
For i:=1 to n do
Begin
New (q);
Writeln ('Vvedite zna4 o4erednogo elementa:');
readln (q^.inf);
p^.next:=q; p:=q;
end;
q^.next:=Nil;//Ввод ЛОСа
PRINT (sag);
COPY (sag, sag2);
PRINT (sag2);
writeln;
writeln ('Lx');
PRINT (sag);
readln;
end.
type
PTListElem = ^TListElem;
TListElem = record
data: String;
count: Integer;
next: PTLIstElem
end;
PTList = ^TList;
TList = object
head, last: PTListElem;
constructor Create;
destructor Free;
function Empty: Boolean;
procedure Push(const value: String);
procedure Pop(var value: TListElem);
procedure PrintList;
end;
constructor TList.Create;
begin
head := nil;
last := nil;
end;
destructor TList.Free;
var
T: PTListElem;
begin
while not Empty do begin
T := head;
head := head^.next;
dispose(T);
end;
end;
function TList.Empty: Boolean;
begin
Empty := head = nil;
end;
procedure TList.Pop(var value: TListElem);
var
T: PTListElem;
begin
if not Empty then begin
T := head;
head := head^.next;
value := T^;
dispose(T);
end;
end;
procedure TList.Push(const value: String);
var
R, first: PTListElem;
begin
first := head;
while (head <> nil) and (head^.data <> value) do
head := head^.next;
if head <> nil then begin
inc(head^.count);
head := first;
end else begin
new(r);
R^.data := value;
R^.count := 1;
R^.next := nil;
head := first;
if Empty then begin
head := R;
last := head;
end else begin
last^.next := R;
last := R;
end;
end;
end;
procedure TList.PrintList;
var
T: TListElem;
begin
while not Empty do begin
Pop(T);
writeln(T.data, ': ', T.count);
end;
end;
var
list: PTList;
begin
new(list, Create);
list^.Push('asd');
list^.Push('asd');
list^.Push('123');
list^.Push('qwerty');
list^.Push('asd');
list^.Push('123');
list^.Push('poiuytrewq');
list^.Push('asd');
list^.PrintList;
dispose(list, Free);
end.