uses Lacrt,GRPfile;


Function Podretezec_vzadu(var s:string):string;
var a,b:longint;
begin
b:=Length(s);

while s[b]=';' do dec(b);

a:=b;
while s[a]<>';' do dec(a);
PodRetezec_vzadu:=Mid(s,a+1,b);
end;

Function Podretezec_vpredu(var s:string):string;
var a:longint;
begin
a:=Pos(';',s);
Podretezec_vpredu:=Copy(s,1,a-1);
end;


Function Retezec(i:longint):string;
var g1,g2:TGrpStream;
    j:longint;
    s:string;

begin
g1.Init(ExeDir+'kasmar.grp#uniidx.inf',grpOpenRead);
g1.Seek(i*4);
g1.Read(j,4);
g1.Done;
writeln('--',j);

g2.Init(ExeDir+'kasmar.grp#uni-ffff.txt',grpOpenRead);
g2.Seek(j);
s:=g2.ReadString;
g2.Done;
writeln('::',s);
Retezec:=s;
end;


var
t1,t2,t3:text;

t4:file;
s,s1,s2,s3:string;
a,b,c,i:longint;
ii:array[0..65535] of longint;

begin
Retezec(0);
Retezec(1);
Retezec(65);


Assign(t1,'uniklasf.txt');
Assign(t2,'unikla1.txt');

Assign(t3,'unikla2.txt');

Assign(t4,'uniidx2.inf');

Reset(t1);
Rewrite(t2);
Rewrite(t3);


for a:=0 to 65535 do ii[a]:=-1;

c:=0;
while not eof(t1) do
   begin
   readln(t1,s);
   a:=Pos(':',s);
   s1:=Copy(s,1,a-1);   {cast pred dvojteckou}
   s2:=Copy(s,a+2,255); {slova po dvojtecce}

   writeln(t2,s1);
   writeln(t3,s2);

   (*
   s1:='$'+s1;
   b:=MyVal(s1);


   delete(s,1,5);
   if s[1]='<' then
      begin
      s2:='c:'+Podretezec_vzadu(s);
      end
      else begin
      s2:='z:'+Podretezec_vpredu(s);
      end;

   if b>$FFFF then Break;

   {writeln(s2);}

   writeln(t2,s2);
   ii[b]:=c;
   inc(c,Length(s2)+2);  {retezec + #13#10}
   *)
   end;

{BlockWrite(t3,ii,SizeOf(ii));}

writeln('Hotovo!');
Close(t1);
Close(t2);
Close(t3);

end.
