 program mmm;
   var
    A:array [7] of string;
    C:array [7] of string;
    b,pom1,pom2:char;
    shifr:string;
    str1,str2,sto1,sto2:integer;
    k,m,mm,Newm:integer;
    p,prov:integer;
    st2,helpstr:string;
    Hchar1,Hchar2:char;
    Hstr1,Hstr2:string;
   begin

/************************************************************/
   A[1]:=' '; A[2]:=':'; A[3]:=''; A[4]:=',';
   A[5]:=''; A[6]:='桨'; A[7]:='.ﬥ'; 
     
   C[1]:=':'; C[2]:='.꠭'; C[3]:=''; C[4]:=' ';
   C[5]:=''; C[6]:=','; C[7]:=''; 
   Clear;
   writeln('᫨   ஢ ᮮ饭   "s".');
   writeln('᫨   ஢ ᮮ饭  "d".');
   writeln('室 -  㣠 .');
   pom1:='s';pom2:='d';
   read(b);
   if b=pom1  then
    begin
     writeln(' ᮮ饭  ஢ :');
     read(st2);
     p:=length(st2);
     prov:=p//2;  /* ⮪  */

     if prov<>0 then 
      begin
       helpstr:=' ';
       ins(helpstr,st2,p+1); /* ஡ -  ⭮*/
      end;     
     shifr:=' '; Newm:=1;
     for mm:=1 to length(st2)/2 do
      begin
       for k:=1 to 7 do
        begin
         for m:=1 to 5 do
          begin
           Hchar1:=st2[Newm]; Hchar2:=A[k][m];
           if Hchar1 = Hchar2 then
             begin
              str1:=k;
              sto1:=m;
             end;
          end;
        end;
       for k:=1 to 7 do
        begin
         for m:=1 to 5 do
          begin
           Hchar1:=st2[Newm+1]; Hchar2:=C[k][m];
           if Hchar1 = Hchar2 then
            begin
             str2:=k;
             sto2:=m;
            end;
          end;
        end;
       
       if str1 <> str2 then
        begin
         Hstr1:=C[str1][sto2];
         p:=length(shifr);
         ins(Hstr1,shifr,p);
         Hstr2:=A[str2][sto1];
         p:=length(shifr);
         ins(Hstr2,shifr,p);
        end;
       else
        begin
         Hstr1:=C[str1][sto1];
         p:=length(shifr);
         ins(Hstr1,shifr,p);
         Hstr2:=A[str2][sto2];
         p:=length(shifr);
         ins(Hstr2,shifr,p);
       end;
       Newm:=Newm+2;
     
      end; /*FOR*/
    
      writeln('஢ ᮮ饭 :');
      write(shifr);
   end;/*IF*/ 
/*--------------------------------------------------------------*/   
   if b=pom2  then
    begin
     writeln(' ᮮ饭  ஢ :');
     read(st2);
     p:=length(st2);
     prov:=p//2;  /* ⮪  */
     if prov<>0 then 
      begin
       helpstr:=' ';
       ins(helpstr,st2,p+1); /* ஡ -  ⭮*/
      end;     
     shifr:=' ';  

     Newm:=1;
     for mm:=1 to length(st2)/2 do
      begin
       for k:=1 to 7 do
        begin
         for m:=1 to 5 do
          begin
           Hchar1:=st2[Newm];
           
           Hchar2:=C[k][m];
        if Hchar1 = Hchar2 then
                           begin
                            str1:=k;
                            sto1:=m;
                           end;
          end;
        end;
       for k:=1 to 7 do
        begin
         for m:=1 to 5 do
          begin
           Hchar1:=st2[Newm+1];
           Hchar2:=A[k][m];
           if Hchar1 = Hchar2 then
                           begin
                            str2:=k;
                            sto2:=m;
                           end;
          end;
        end;
       if str1 <> str2 then
        begin
         Hstr1:=A[str1][sto2];
         p:=length(shifr);
         ins(Hstr1,shifr,p);
         Hstr2:=C[str2][sto1];
         p:=length(shifr);
         ins(Hstr2,shifr,p);
        end;
       else
        begin
         Hstr1:=A[str1][sto1];
         p:=length(shifr);
         ins(Hstr1,shifr,p);
         Hstr2:=C[str2][sto2];
         p:=length(shifr);
         ins(Hstr2,shifr,p);
       end;
       Newm:=Newm+2;
     
      end; /*FOR*/
    
      writeln('஢ ᮮ饭 :');
      write(shifr);
   end;/*IF*/ 
  press;
end.
