#include<iostream>
#include<cstdio>
#include<string>
using namespace std;
struct node{
node * left;
node * right;
char data;
};
node * create(string pre,string in){
if(pre.length()>0){
node * root;
root= new node;
root->data=pre[0];
int index=in.find(root->data);
root->left=create(pre.substr(1,index),in.substr(0,index));
root->right=create(pre.substr(index+1),in.substr(index+1));
return root;
}
else
return NULL;
};
void prinpos(node * root){
if(root->left)
prinpos(root->left);
if(root->right)
prinpos(root->right);
printf("%c",root->data);
};
int main(){
string pre,in;
while(cin>>pre>>in){
node * root=create(pre,in);
prinpos(root);
printf("\n");
}
return 0;
}
#include<cstdio>
#include<string>
using namespace std;
struct node{
node * left;
node * right;
char data;
};
node * create(string pre,string in){
if(pre.length()>0){
node * root;
root= new node;
root->data=pre[0];
int index=in.find(root->data);
root->left=create(pre.substr(1,index),in.substr(0,index));
root->right=create(pre.substr(index+1),in.substr(index+1));
return root;
}
else
return NULL;
};
void prinpos(node * root){
if(root->left)
prinpos(root->left);
if(root->right)
prinpos(root->right);
printf("%c",root->data);
};
int main(){
string pre,in;
while(cin>>pre>>in){
node * root=create(pre,in);
prinpos(root);
printf("\n");
}
return 0;
}