#include <stdio.h>
#include <stdlib.h>
#include <string.h>
typedef struct BTNode{
	char data;
	struct BTNode *left,*right;
}BTNode,*BTree;
void build(BTree *t,char *pre,char *in,int len){
	if (len<=0)
	{
		*t=NULL;
		return;
	}
	int pos=strchr(in,pre[0])-in;
	*t=(BTNode *)malloc(sizeof(BTNode));
	(*t)->data=*pre;
	build(&(*t)->left,pre+1,in,pos);
	build(&(*t)->right,pre+pos+1,in+pos+1,len-pos-1);
}
void postorder(BTree t){
	if (t)
	{
		postorder(t->left);
		postorder(t->right);
		printf("%c",t->data);
	}
}
void clean(BTree *t){
	if (*t)
	{
		clean(&(*t)->left);
		clean(&(*t)->right);
		free(*t);
	}
}
int main(){
	BTree root;
	char pre[30],in[30];
//	freopen("1.txt","r",stdin);
	while (scanf("%s %s",pre,in)!=EOF)
	{
		build(&root,pre,in,strlen(pre));
		postorder(root);
		clean(&root);
		printf("\n");
	}
//	fclose(stdin);
	return 0;
}
/**************************************************************
	Problem: 2193
	User: admin
	Language: C
	Result: Accepted
	Time:13 ms
	Memory:1144 kb
****************************************************************/