//* Problem  : H - Tree
//* Contest  : UzhNU Local
//* Origin   : Ulm-1997
//* Type     : Solution
//* Date     : 2008.02.04
//* Author   : alt
//* Language : C++
//* Compiler : Microsoft Visual C++ 6.0
//* Algoritm : 

#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>

struct tree_elem{
	char mark;
	int left, right;
}a[100];

int plist;

char s1[100];
char s2[100];

int pos;

int tree(char *s2)
{
	if (!s1[pos] || !s2[0]) return 0;
	int p = ++plist;
	a[p].mark = s1[pos];
	char *ps = s2; while (*ps != s1[pos]) ps++;
	*ps = 0; ps++;  pos++;
	a[p].left = tree(s2);
	a[p].right = tree(ps);
	return p;
}

void output(int p)
{
	if (!p) return;
	output(a[p].left);
	output(a[p].right);
	putchar(a[p].mark);
}

int main()
{
	while (1)
	{
		s1[0] = 0; scanf("%s%s", s1, s2); if (!s1[0]) break;
		pos = 0; plist = 0;
		int p = tree(s2);
		output(p);
		putchar('\n');
	}
	return 0;
}