#include <string>
#include <iostream>
using namespace std;
struct TreeNode
{
char data;
TreeNode *left;
TreeNode *right;
TreeNode(char c):data(c),left(NULL),right(NULL){}
};
TreeNode* build(const string & str1, const string &str2);
void postorder(TreeNode * r);
int main(int nums ,char ** args)
{
ios::sync_with_stdio(false);
string str1,str2;
while(cin>>str1>>str2)
{
TreeNode*r=build(str1,str2);
postorder(r);
cout<<endl;
}
return 0;
}
TreeNode* build(const string & str1, const string &str2)
{
if(str1.size()==0)
{return NULL;}
int pos=str2.find(str1[0]);
TreeNode* r=new TreeNode(str1[0]);
r->left=build(str1.substr(1,pos),str2.substr(0,pos));
r->right=build(str1.substr(1+pos),str2.substr(1+pos));
return r;
}
void postorder(TreeNode * r)
{
if(r==NULL) return;
postorder(r->left);
postorder(r->right);
cout<<r->data;
}