#include <iostream>
#include <string>
using namespace std;
string constructTree(const string &pr, const string &in)
{
    if (pr.size() <= 1 && in.size() <= 1)
        return pr;
    else
    {
        size_t pos = in.find(pr[0]);
        return constructTree(pr.substr(1, pos), in.substr(0, pos)) +
               constructTree(pr.substr(pos + 1, pr.size() - pos - 1), in.substr(pos + 1, in.size() - pos - 1)) +
               pr[0];
    }
}
int main()
{
    string s1, s2;
    while (cin >> s1 >> s2)
        cout << constructTree(s1, s2) << endl;
    return 0;
}