void root( char *mid, char *lst ){
char a, *p, *q;
if( !*mid )
return ;
p = lst + strlen(lst) - 1;
printf( "%c", *p );
q = strchr( mid, *p );
*p = 0;
p = q - mid + lst;
a = *p;
*p = 0;
*q = 0;
root( mid, lst );
*p = a;
root( q + 1, p );
}
int main()
{
freopen("prime.in","r",stdin);
freopen("prime.out","w",stdout);
char mid[9] ;
char lst[9] ;
cin >> mid >> lst;
root( mid, lst );
printf( "\n" );
return 0;
}
char a, *p, *q;
if( !*mid )
return ;
p = lst + strlen(lst) - 1;
printf( "%c", *p );
q = strchr( mid, *p );
*p = 0;
p = q - mid + lst;
a = *p;
*p = 0;
*q = 0;
root( mid, lst );
*p = a;
root( q + 1, p );
}
int main()
{
freopen("prime.in","r",stdin);
freopen("prime.out","w",stdout);
char mid[9] ;
char lst[9] ;
cin >> mid >> lst;
root( mid, lst );
printf( "\n" );
return 0;
}