#include <iostream>
#include <string>
using namespace std;
typedef struct Node
{
char data;
Node *lchild,*rchild;
}Node,*Bitree;
Bitree creat(string s1,string s2)
{
if(s1.length()==0)
return NULL;
Node *root;
root = new Node;
root->data = s1[0];//第二次做,竟然忘家了
size_t pos = s2.find(s1[0]);
root->lchild=creat(s1.substr(1,pos),s2.substr(0,pos));//从index开始,共num个字符,不是到第num
root->rchild=creat(s1.substr(pos+1),s2.substr(pos+1));
return root;
}
void postorder(Node *root)
{
if(root)
{
postorder(root->lchild);
postorder(root->rchild);
cout<<root->data;
}
}
int main()
{
int i,j,k;
string s1,s2;
while(cin>>s1>>s2)
{
Node *root;
root = creat(s1,s2);
postorder(root);
cout<<endl;
}
return 0;
}