#include<iostream>
using namespace std;
const int max1 = 17;
struct tree {
int lc, rc;
char data;
};
tree tree1[max1];
char z[max1], h[max1], l[max1];
void jian(int hhead,int zhead,int g)
{
int j=0;
for (; j < g; j++) {
if (h[hhead] == z[zhead+j])break;
}
tree1[hhead].data = h[hhead];
if (g - j - 1 > 0) {
tree1[hhead].rc = hhead + 1;
}
if (j>0) {
tree1[hhead].lc = hhead + (g - j);
}
if (j>=1) jian(hhead + g - j, zhead, j);
if (g - j - 1 >= 1) jian(hhead + 1, zhead + j + 1, g - j - 1);
}
void chu(int n) {
if (tree1[n].data != NULL)cout << tree1[n].data;
if (tree1[n].lc != NULL) chu(tree1[n].lc);
if (tree1[n].rc != NULL) chu(tree1[n].rc);
}
int main() {
char a;
int n = 0, m;
for (; (a = getchar()) != '\n'; n++)z[n] = a;
m = n-1;
for (; (a = getchar()) != '\n'; m--)h[m] = a;
jian(0, 0, n);
chu(0);
return 0;
}