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.
sums = lambda n: int(n * (n + 1) / 2)  # sum from 1 to n
def im(): return map(int, input().split())
def il(): return list(map(int, input().split()))
def ii(): return int(input())

str1 = input()
str2 = input()
str3 = input()

freq1 = [0] * 26
freq2 = [0] * 26
freq3 = [0] * 26

for i in range(len(str1)):
    freq1[ord(str1[i])-97]+=1
for i in range(len(str2)):
    freq2[ord(str2[i])-97]+=1
for i in range(len(str3)):
    freq3[ord(str3[i])-97]+=1

freq1cpy = freq1.copy()
freq4 = [0] * 26
freq5 = [0] * 26


minVal=0
minVal2=0
minVal3=0
minVal4=0

isIt1=True
for i in range(26):
    if freq1[i] < freq2[i]:
        isIt1=False
        freq1=freq1cpy.copy()
        break
    elif freq1[i] >= freq2[i] and freq2[i]>0:
        freq4[i]= freq1[i]//freq2[i]
        freq1[i]%=freq2[i]


res=""
if isIt1:
    # find the minimum non zero value in freq4
    minVal= freq4[ord(str2[0])-97]
    for i in range(26):
        if freq4[i]>0 and freq4[i]<minVal:
            minVal=freq4[i]

    res+= str2 * minVal

    for i in range(26):
        freq1[i]+= (freq4[i]-minVal)*freq2[i] 

freq1cpy1 = freq1.copy()
isIt2=True
for i in range(26):
    if freq1[i] < freq3[i]:
        isIt2=False
        freq1=freq1cpy1.copy()
        break
    elif freq1[i] >= freq3[i] and freq3[i]>0:
        freq5[i]+= freq1[i]//freq3[i]
        freq1[i]%=freq3[i]





if isIt2:
    # find the minimum non zero value in freq5
    minVal2= freq5[ord(str3[0])-97]
    for i in range(26):
        if freq5[i]>0 and freq5[i]<minVal2:
            minVal2=freq5[i]
            
    res+= str3 * minVal2

    for i in range(26):
        freq1[i]+= (freq5[i]-minVal2)*freq3[i]


for i in range(26):
    if freq1[i]>0:
        res+= chr(i+97)*freq1[i]


# find freqeuncy of res
freqRes = [0] * 26
for i in range(len(res)):
    freqRes[ord(res[i])-97]+=1

for i in range(26):
    if freqRes[i] != freq1cpy[i]:
        res+= chr(i+97)*(freq1cpy[i]-freqRes[i])

#print(res)



freq1 = freq1cpy.copy()
freq4 = [0] * 26
freq5 = [0] * 26

isIt1=True
for i in range(26):
    if freq1[i] < freq3[i]:
        isIt1=False
        freq1=freq1cpy.copy()
        break
    elif freq1[i] >= freq3[i] and freq3[i]>0:
        freq4[i]= freq1[i]//freq3[i]
        freq1[i]%=freq3[i]
    
res2=""
if isIt1:
    # find the minimum non zero value in freq4
    minVal3= freq4[ord(str3[0])-97]
    for i in range(26):
        if freq4[i]>0 and freq4[i]<minVal3:
            minVal3=freq4[i]
            
    res2+= str3 * minVal3

    for i in range(26):
        freq1[i]+= (freq4[i]-minVal3)*freq3[i] 

freq1cpy1 = freq1.copy()
isIt2=True
for i in range(26):
    if freq1[i] < freq2[i]:
        isIt2=False
        freq1=freq1cpy1.copy()
        break
    elif freq1[i] >= freq2[i] and freq2[i]>0:
        freq5[i]+= freq1[i]//freq2[i]
        freq1[i]%=freq2[i]



if isIt2:
    # find the minimum non zero value in freq5
    minVal4= freq5[ord(str2[0])-97]
    for i in range(26):
        if freq5[i]>0 and freq5[i]<minVal4:
            minVal4=freq5[i]
            

    res2+= str2 * minVal4

    for i in range(26):
        freq1[i]+= (freq5[i]-minVal4)*freq2[i]


for i in range(26):
    if freq1[i]>0:
        res2+= chr(i+97)*freq1[i]

# find freqeuncy of res
freqRes = [0] * 26
for i in range(len(res2)):
    freqRes[ord(res2[i])-97]+=1

for i in range(26):
    if freqRes[i] != freq1cpy[i]:
        res2+= chr(i+97)*(freq1cpy[i]-freqRes[i])

#print(res)

if minVal+minVal2 > minVal3+minVal4:
    print(res)
else:
    print(res2)

            
    

