http://oj.tsinsen.com/A1132
#include "bits/stdc++.h"
using namespace std;
string In, Post;
void Solve(int PostB, int PostE, int InB, int InE) {
if (PostB >= PostE) return;
int RootPos = In.find(Post[PostE - 1]);
cout << In[RootPos];
Solve(PostB, PostB + RootPos - InB, InB, RootPos);
Solve(PostB + RootPos - InB, PostE - 1, RootPos + 1, InE);
}
int main() {
cin >> In >> Post;
int size = In.size();
Solve(0, size, 0, size);
return 0;
}