var
   Alph, P:String;
   Ord, OrdK, T: array[1..12] of integer;
   b:array[1..255] of boolean;
   i,j:integer;
   n, m,l:integer;
   k:longint;
begin
///   assign(Input,'Input.txt');
//   assign(Output,'Output.txt');
   reset(input);
   rewrite(output);
   readln(Alph);
   readln(p);
   read(k);
   n:=length(alph);
   for i:=1 to n do ord[i]:=pos(P[i],Alph);
   for i:=1 to n do
      begin
         m:=0;
         For j:=i+1 to n do
            if ord[j]<ord[i] then m:=m+1;
         T[i]:=m;
      end;
   for i:=1 to n do
      begin
      	 Ordk[n-i+1]:= k mod i;
         K:=k div i;
      end;
   m:=0;
  for i:=n downto 1 do
     begin
        l:=(m+t[i]+ordK[i]) mod (n-i+1);
        m:=(m+t[i]+ordK[i]) div (n-i+1);
        T[i]:=l;
     end;
  if (m>0) or (k>0) then write('IMPOSSIBLE')
     else
   	begin
      	   for i:=1 to n do  b[i]:=true;
           for i:=1 to n do
              begin
            	j:=0; m:=0;
                repeat
               	  j:=j+1;
                  if b[j] then m:=m+1;
                until m>T[i];
                write(alph[j]);
                b[j]:=false;
              end;
       end;
end.