#include<bits/stdc++.h>
using namespace std;
char a[30],b[30];
int root;
void Find(int x,int y){
int k=root;
int j;
if(x<y){
cout<<k;
for(j=x;j<=y;j++){
if(b[j]==a[root])
break;
}
root++;
Find(x,j-1);
Find(j+1,y);
cout<<k;
cout<<a[k];
}
else if(x==y){
cout<<a[root];
cout<<root<<endl;
root++;
}
}
int main(){
while(cin>>a>>b){
int lenth=strlen(a);
root=0;
Find(0,lenth-1);
cout<<endl;
}
return 0;
}