#include <iostream> #include <algorithm> #include <string> using namespace std; string s1, s2; typedef struct TNode { char data; struct TNode *lchild, *rchild; }*BTree; void build(BTree& T, int start1, int end1, int start2, int end2) { if(start1 > end1) { T = NULL; return; } else { T = new TNode; T->data = s1[start1]; int index = s2.find(s1[start1], start2); build(T->lchild, start1+1, start1+index-start2, start2, index-1); build(T->rchild, start1+index-start2 +1, start1+index-start2+end2-index, index+1, end2); } } void postVisit(BTree T) { if(T) { postVisit(T->lchild); postVisit(T->rchild); cout << T->data; } } int main() { BTree T; while(cin >> s1 >> s2) { build(T , 0, s1.size()-1, 0, s2.size()-1); postVisit(T); cout << endl; T = NULL; } return 0; }