const
 count		= 20;
 len		= 20;
 first_numb	= 12;
var
  DB	     : array [1..count,1..(len+2)] of char;
  tmp        : array [1..(len+2)] of char;
  INP	     : FILE of CHAR;
  i,j,k,l    : integer;
  ch	     : char;

begin
  Assign(INP,'phones.txt');
  {$I-}
    Reset(INP);
    If IOResult <> 0 then
     begin
       WriteLn('File ''phones.txt'' not found');
       Halt(255);
     end;
  {$I+}

  for i := 1 to count do
   begin
     for j := 1 to (len+2) do Read(INP,DB[i,j]);
   end;
  Close(INP);

  for k := first_numb+8 downto first_numb do
   if not (k in [first_numb+3,first_numb+6]) then
    begin
      for i := 1 to count-1 do
       for j:=count-1 downto i do
        begin
          if DB[j+1,k] > DB[j,k] then
           begin
{Var 1}      Move(DB[j],tmp,len+2);
             Move(DB[j+1],DB[j],len+2);
             Move(tmp,DB[j+1],len+2);
{Var 2       for l := 1 to len+2 do tmp[l]  := DB[j,l];
             for l := 1 to len+2 do DB[j,l] := DB[j+1,l];
             for l := 1 to len+2 do DB[j+1,l] := tmp[l]; }
           end;
        end;
    end;
  for i := 1 to count do
   for j := 1 to len+2 do Write(DB[i,j]);
  WriteLn('End.');
end.