#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>
using namespace std;
string LDR,DLR;
void tree(string x,string y){
if(x.empty()) return ;
char root=x[0];
int k=y.find(root);
x.erase(x.begin());
tree(x.substr(0,k),y.substr(0,k));
tree(x.substr(k),y.substr(k+1));
cout<<root;
}
int main(){
getline(cin,LDR);
getline(cin,DLR);
tree(DLR,LDR);
return 0;
}