#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
using namespace std;
#define inf 0x3f3f3f3f
typedef struct node
{
char x;
struct node *lc,*rc;
}node,*tree;
char pre[100],in[100],post[100];
void topost(char pre[],char in[],char post[],int l)
{
int i;
if(l<=0) return ;
for(i=0;i<l;i++)
if(in[i]==pre[0]) break;
post[l-1]=pre[0];
topost(pre+1,in,post,i);
topost(pre+i+1,in+i+1,post+i,l-1-i);
}
int main ()
{
int i,j,l;
while(gets(pre))
{
gets(in);
l=strlen(pre);
topost(pre,in,post,l);
for(i=0;i<l;i++)
printf("%c",post[i]);
printf("\n");
}
return 0;
}
//FDXEAG
//XDEFAG
//XEDGAF