#include<bits/stdc++.h>
#define size 100000
using namespace std;
main()
{
char a[size+1],b[size+1],c[size+1];
// freopen("in.txt","r",stdin);
cin>>a>>b>>c;
int h1[26],h2[26],h3[26],l1,l2,l3;
l1=strlen(a);
l2=strlen(b);
l3=strlen(c);
memset(h1,0,sizeof(h1));
memset(h2,0,sizeof(h2));
memset(h3,0,sizeof(h3));
for(int i=0;i<l1;++i)
++h1[a[i]-'a'];
for(int i=0;i<l2;++i)
++h2[b[i]-'a'];
for(int i=0;i<l3;++i)
++h3[c[i]-'a'];
int cur=0,val,ans=INT_MAX,ma=0,b1=0,c1=0,flag;
for(int i=0;i<l1;++i)
{
cur=i;
flag=0;
for(int j=0;j<26;++j)
{
if(h1[j]-(cur*h2[j])<0)
{
flag=1;
break;
}
}
if(flag==0)
{
ans=INT_MAX;
for(int j=0;j<26;++j)
{
if(h3[j]!=0)
{
val=(h1[j]-(h2[j]*cur))/h3[j];
if(val<=0)
val=0;
ans=min(ans,val);
}
}
if(ma<cur+ans)
{
ma=cur+ans;
b1=cur;
c1=ans;
}
}
}
int cur1=0,ma1=0,ans1=INT_MAX,b2=0,c2=0;
for(int i=0;i<l1;++i)
{
cur1=i;
flag=0;
for(int j=0;j<26;++j)
{
if(h1[j]-(cur*h3[j])<0)
{
flag=1;
break;
}
}
if(flag==0)
{
ans1=INT_MAX;
for(int j=0;j<26;++j)
{
if(h2[j]!=0)
{
val=(h1[j]-(h3[j]*cur))/h2[j];
if(val<=0)
val=0;
ans1=min(ans1,val);
}
}
if(ma1<cur1+ans1)
{
ma1=cur1+ans1;
b2=cur;
c2=ans;
}
}
}
// cout<<ma<<endl;
if(ma1>ma)
{
ma=ma1;
cur=cur1;
ans=ans1;
b1=b2;
c1=c2;
}
cur=ma;
for(int i=0;i<26;++i)
h1[i]-=(h2[i]*cur+h3[i]*ans);
for(int i=0;i<cur;++i)
cout<<b;
for(int i=0;i<ans;++i)
cout<<c;
for(int i=0;i<26;++i)
{
for(int j=0;j<h1[i];++j)
c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