#include <iostream>
#include <istream>
#include<string.h>
using namespace std;
typedef struct bitree
{
char data;
struct bitree* left;
struct bitree* right;
}BiTree;
BiTree * creat (string sq,string sz)
{
int L = sq.size();
if(L == 0)return NULL;
BiTree *root = (BiTree*)malloc(sizeof(BiTree));
root->data = sq[0];
int pos = sz.find(sq[0]);
root->left = creat(sq.substr(1,pos),sz.substr(0,pos));
root->right = creat(sq.substr(pos+1,L-pos),sz.substr(pos+1,L-pos));
return root;
}
void PostOrder(BiTree* t)
{
if(t==NULL)
{
return;
}
PostOrder(t->left);
PostOrder(t->right);
cout<<t->data;
}
int main() {
string sq,sz;
while(cin>>sq>>sz)
{
BiTree* t = creat(sq,sz);
PostOrder(t);
}
}
// 64 位输出请用 printf("%lld")