{
Written by Fyodor Menshikov 10.02.2004
21:54-22:14
}
{$R+,Q+}
type
   integer=longint;

   function fact(n:integer):integer;
   begin
      if n=0 then
         fact:=1
      else
         fact:=n*fact(n-1);
   end;

   procedure string2int(alphabet,s:string;var p:integer);
   var
      n,i:integer;
   begin
      p:=0;
      n:=length(alphabet);
      while n>0 do begin
         p:=p*n+pos(s[1],alphabet)-1;
         dec(n);
         delete(alphabet,pos(s[1],alphabet),1);
         delete(s,1,1);
      end;   
   end;

   procedure int2string(alphabet:string;p:integer;var s:string);
   var
      i,n,d:integer;
   begin
      n:=length(alphabet);
      s:='';
      for i:=n downto 1 do begin
         d:=p div fact(i-1);
         s:=s+alphabet[d+1];
         delete(alphabet,d+1,1);
         p:=p mod fact(i-1);
      end;
   end;

var
   alphabet:string;
   s1,s2:string;
   n,k,pos1,pos2:integer;
begin
//   assign(input,'input.txt');
   reset(input);
//   assign(output,'output.txt');
   rewrite(output);
   readln(alphabet);
   readln(s1);
   readln(k);
   n:=length(alphabet);
   string2int(alphabet,s1,pos1);
   int2string(alphabet,pos1,s1);
   pos2:=pos1+k;
   if pos2>=fact(n) then begin
      writeln('IMPOSSIBLE');
      halt;
   end;
   int2string(alphabet,pos2,s2);
   writeln(s2);
end.