include

include

include

include

using namespace std;
void tree(string s1,string s2){
int len1=s1.size();
int len2=s2.size();
if(len1>0){
char ch=s2[len2-1]; //根节点
cout<<ch; //每次递归输出根节点
int pos=s1.find(ch); //在s1中找到ch出现的位置
tree(s1.substr(0,pos),s2.substr(0,pos)); //递归左子树
tree(s1.substr(pos+1),s2.substr(pos,len1-pos-1)); //递归右子树
}
}
int main() {
string str1,str2;
cin>>str1>>str2;
tree(str1,str2); //构建左子树
return 0;
}