program acmxz;
var sx,sz,s:string;
    i,j:longint;

procedure work(sx,sz:string);
  var l,k:integer;
   begin
     if sx<>'' then
       begin
         l:=length(sx);
         k:=pos(sx[1],sz);
         work(copy(sx,2,k-1),copy(sz,1,k-1));
         work(copy(sx,k+1,l-k),copy(sz,k+1,l-k));
         write(sx[1]);
       end;
   end;

procedure init;
  begin
    readln(s);
    i:=pos(' ',s);
    sx:=copy(s,1,i-1);
    sz:=copy(s,i+1,i-1);
  end;

begin
  while not eof do
    begin
      init;
      work(sx,sz);
      writeln;
    end;
end.
/**************************************************************
	Problem: 2121
	User: admin
	Language: Pascal
	Result: Wrong Answer
****************************************************************/