Professor GukiZ doesn't accept string as they are. He likes to swap some letters in string to obtain a new one.

GukiZ has strings *a*, *b*, and *c*. He wants to obtain string *k* by swapping some letters in *a*, so that *k* should contain as many non-overlapping substrings equal either to *b* or *c* as possible. Substring of string *x* is a string formed by consecutive segment of characters from *x*. Two substrings of string *x* overlap if there is position *i* in string *x* occupied by both of them.

GukiZ was disappointed because none of his students managed to solve the problem. Can you help them and find one of possible strings *k*?
The first line contains string *a*, the second line contains string *b*, and the third line contains string *c* (1 ≤ |*a*|, |*b*|, |*c*| ≤ 10<sup class="upper-index">5</sup>, where |*s*| denotes the length of string *s*).

All three strings consist only of lowercase English letters. 

It is possible that *b* and *c* coincide.
import sys, os.path
from collections import*
from copy import*
import math
mod=10**9+7
if(os.path.exists('input.txt')):
    sys.stdin = open("input.txt","r")
    sys.stdout = open("output.txt","w")   

a=input()
b=input()
c=input()
d=Counter(a)
d1=Counter(a)
d2=Counter(a)
dic=Counter(a)
n=len(a)
n1=len(b)
n2=len(c)
cnt=0
cnt1=0
i=0
while(n!=0):
    if b[i%n1] in d1:
        if(d1[b[i%n1]]>0):
            cnt+=1
            d1[b[i%n1]]-=1
        else:
            break
    else:
        break
    n-=1
    i+=1

i=0
n=len(a)
while(n!=0):
    if c[i%n1] in d2:
        if(d2[c[i%n2]]>0):
            cnt1+=1
            d2[c[i%n2]]-=1
        else:
            break
    else:
        break
    n-=1
    i+=1

b1=cnt//n1
c1=cnt1//n2
res=''
if(b1>=c1):
    res+=b*b1
    for i in res:
        d[i]-=1
    i=0
    ct=0
    while(ct//n2!=c1):
        if c[i%n2] in d:
            if(d[c[i%n2]]>0):
                ct+=1
                d[c[i%n2]]-=1
            else:
                break
        else:
            break
        i+=1
    res+=(ct//n2)*c

for i in res:
    dic[i]-=1
for i in dic:
    res+=dic[i]*i
print(res)


    




    





    